is there a way to change/refresh token when data in db changes such as role?

Hi, I had a project using NextAuth as my provider and the JWT strategy. When I use the database strategy, whenever I change the user’s role, they are automatically redirected to their own page. However, when I use the JWT strategy, I have to log out and log in again to get the newest token. Is there any way I can change the behavior so the token automatically refreshes when I change the role?
5 Replies
arete
areteOP2y ago
I need the automatic behavior when the session changes
Rockstaa8055
Rockstaa80552y ago
Unfortunately that's not possible with JWTs. They are stateless, which means once created there is no way to revoke or modify their content.
arete
areteOP2y ago
so i should just use the database strat?
Rockstaa8055
Rockstaa80552y ago
Yup
arete
areteOP2y ago
sed to leave the edge middleware:((
Want results from more Discord servers?
Add your server