I am using beta.1 version of this great lib and I run into an issue. When I use refresh token and update user field which is included in token as custom claim it does'nt get updated in new token. I think new (refreshed) token should contain new (updated) user field.
My usage:
public function getJWTCustomClaims()
{
return [
'user' => [
'email' => $this->email,
'firstName' => $this->first_name,
'lastName' => $this->last_name,
'avatar' => $this->avatar
]
];
}
How can I achieve desired functionality?
You can set the persistent claims in the config here
I think this should not be closed yet. I have set the persistent and required claims as documented but the issue is still there.
hey i have same issue and solved it, i would just add my solution here for other who might face this problem in the future,
just change your refreshtoken function to this:
public function refresh()
{
return $this->respondWithToken(JWTAuth::fromUser(Auth::user()));
}
protected function respondWithToken($token)
{
return response()->json([
'access_token' => $token,
'token_type' => 'bearer',
'expires_in' => auth()->factory()->getTTL() * 60,
]);
}
Same Issue
I've tried @tymondesigns suggestion and it does not fix the issue... something isn't working correctly or the docs don't cover the proper process.
You could try this
https://github.com/Blog-Ecommerce/jwt-auth/
hey i have same issue and solved it, i would just add my solution here for other who might face this problem in the future,
just change your refreshtoken function to this:
public function refresh()
{
return $this->respondWithToken(JWTAuth::fromUser(Auth::user()));
}
protected function respondWithToken($token)
{
return response()->json([
'access_token' => $token,
'token_type' => 'bearer',
'expires_in' => auth()->factory()->getTTL() * 60,
]);
}
I had the same problem on user profile updating.
This worked form me!!!
Thanks @ralpdexterbongato !!!
Most helpful comment
I think this should not be closed yet. I have set the persistent and required claims as documented but the issue is still there.