I am trying to get data included in a JWT Token with Angular 6.
I can do the login action, and return the token with Lumen 5.6 - tymondesigns/jwt-auth
But then, when I print it in JS, I get:
iat: 1531073200
iss: "https://api.kz-api.test/auth/login"
jti: "taCmXQoo0jWs4y7t"
nbf: 1531073200
prv: "87e0af1ef9fd15812fdec97153a14e0b047546aa"
sub: 1
I thought I should have the user object in ‘sub’ array as it identifies the subject of the JWT, but I can only find 1…. What’s wrong with my code:
/**
* Authenticate a user and return the token if the provided credentials are correct.
*
* @return mixed
*/
public function authenticate()
{
// Find the user by email
$user = User::where('email', $this->request->input('email'))->first();
if (!$user) {
return response()->json('login.wrong_email', HttpResponse::HTTP_UNAUTHORIZED);
}
$credentials = Input::only('email', 'password');
if (!$token = JWTAuth::attempt($credentials)) {
return response()->json('login.wrong_password', HttpResponse::HTTP_UNAUTHORIZED);
}
return response()->json(compact('token'), HttpResponse::HTTP_ACCEPTED);
}