jwt-auth
jwt-auth copied to clipboard
Customizing TTL per user
I've been trying to create custom TTL and expiry for tokens based on my user roles for example admin 24 hr and regular user 1 hour. Is that possible?
@aconital Yes,just do this
$token = auth()->setTTL(7200)->attempt($credentials);
see the doc : https://jwt-auth.readthedocs.io/en/develop/auth-guard/
@aconital Yes,just do this
$token = auth()->setTTL(7200)->attempt($credentials);
see the doc : https://jwt-auth.readthedocs.io/en/develop/auth-guard/
It's Not Working
@aconital @dy7338 Did you ever solve this? I have similar issue where the default TTL is always being applied when i specify a different TTL.
@aconital @dy7338 Did you ever solve this? I have similar issue where the default TTL is always being applied when i specify a different TTL.
1.
I'm set .env
like this
JWT_TTL=4320
JWT_REFRESH_TTL=43200
then set Middleware
like this
$token = $this->auth->refresh ();
return response ()->json ($token................)
It can notify the mobile token to expire and return to the mobile new token.The server will only notify you once.
2.
You can get the new one by refreshing the token before it expires.