Skip to content

Commit 2e1f06c

Browse files
committed
getting token with user details
1 parent 1ed7f5d commit 2e1f06c

3 files changed

Lines changed: 12 additions & 4 deletions

File tree

app/Http/Controllers/AuthController.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
use App\Http\Controllers\Controller;
1212
use Illuminate\Http\Request;
13+
use Illuminate\Support\Facades\Auth;
1314
use Tymon\JWTAuth\JWTAuth;
1415
class AuthController extends Controller
1516
{
@@ -50,6 +51,12 @@ public function postLogin(Request $request)
5051

5152
}
5253

53-
return response()->json(compact('token'));
54+
55+
56+
// return response()->json(compact('token'));
57+
58+
$response = compact('token');
59+
$response['user'] = Auth::user();
60+
return response()->json($response);
5461
}
5562
}

bootstrap/app.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@
6565
// ]);
6666

6767
$app->routeMiddleware([
68-
// 'auth' => App\Http\Middleware\Authenticate::class,
69-
'jwt-auth' => \Tymon\JWTAuth\Http\Middleware\Authenticate::class,
68+
'auth' => App\Http\Middleware\Authenticate::class,
69+
// 'jwt-auth' => \Tymon\JWTAuth\Http\Middleware\Authenticate::class,
7070
]);
7171

7272
/*

routes/web.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717

1818
$router->post('/auth/login', 'AuthController@postLogin');
1919

20-
$router->group(['middleware' => 'jwt-auth'], function() use ($router)
20+
//$router->group(['middleware' => 'jwt-auth'], function() use ($router)
21+
$router->group(['middleware' => 'auth:api'], function() use ($router)
2122
{
2223
$router->get('/test', function() {
2324
return response()->json([

0 commit comments

Comments
 (0)