Jwt-auth: Refresh token not updates user custom claims

Created on 8 Dec 2016  路  7Comments  路  Source: tymondesigns/jwt-auth

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?

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.

All 7 comments

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.

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 !!!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kennethtomagan picture kennethtomagan  路  25Comments

mtpultz picture mtpultz  路  114Comments

mcblum picture mcblum  路  48Comments

pereiracinthiag picture pereiracinthiag  路  32Comments

rajabishek picture rajabishek  路  49Comments