I am creating login api in laravel 5.1.
I have created user authentication in controller
try {
// verify the credentials and create a token for the user
if (! $token = JWTAuth::attempt($credentials)) {
$response['error'] = 'true';
$response['data'] = 'invalid_credentials';
return response()->json($response);
}
} catch (JWTException $e) {
// something went wrong
$response['error'] = 'true';
$response['data'] = 'could_not_create_token';
return response()->json($response);
}
$response['error'] = 'false';
$response['data'] = ['token'=>$token];
return response()->json($response);
It is working, and successfully generating token.
but in this code before return, if check login dd(Auth::check());
It throws
Status 500 Internal Server Error
Then here, How can I get user from database after successful login?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire