Skip to content

Commit ff2a743

Browse files
committed
berhasil login dan mendapatkan data user
1 parent 1d542af commit ff2a743

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

app/Http/Controllers/Auth/LoginController.php

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function login(Request $request)
4646
{
4747
$credentials = $request->only('name', 'password');
4848

49-
if ($token = $this->guard()->attempt($credentials)) {
49+
if ($token = JWTAuth::attempt($credentials)) {
5050
return $this->respondWithToken($token);
5151
}
5252

@@ -65,17 +65,8 @@ protected function respondWithToken($token)
6565
return response()->json([
6666
'access_token' => $token,
6767
'token_type' => 'bearer',
68-
'expires_in' => $this->guard()->factory()->getTTL() * 60
68+
'expires_in' => $this->guard()->factory()->getTTL() * 60,
69+
'user' => Auth::user(),
6970
]);
7071
}
71-
72-
/**
73-
* Get the guard to be used during authentication.
74-
*
75-
* @return \Illuminate\Contracts\Auth\Guard
76-
*/
77-
public function guard()
78-
{
79-
return Auth::guard('api');
80-
}
8172
}

0 commit comments

Comments
 (0)