-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is it possible to invalidate users if using jwt? #662
Comments
Great question! No it's not is the short answer, this is one of the challenges for JWT. The best way around this that folks usually use to address this situation is to have a short session expiry time (e.g. 10-15 minutes) and use logic when refreshing the token to check to see if an account is still valid / flagged / etc. In the case of NextAuth.js, this logic would typically be placed in the NextAuth.js actually has some great options if you want to do this, you can set https://github.com/nextauthjs/next-auth-example/blob/main/pages/_app.js The only downside to short session expiry times is that the user will need to sign in again if the session expires - which might be fine depending on the context of the app. If their account is still enabled and not blocked, it should be as simple as clicking the sign in button again (in theory you could even automate this with silent login if you wanted to get fancy, though NextAuth.js doesn't include explicit code to do this for you currently). |
Thanks @iaincollins sorry for not mentioning explicitly, Can we add jwt token invalidation by checking if user account is present in the database upon appLaunch/routeChange in core Next-Auth lib itself? |
Hi there! It looks like this issue hasn't had any activity for a while. It will be closed if no further activity occurs. If you think your issue is still relevant, feel free to comment on it to keep ot open. Thanks! |
Hi there! It looks like this issue hasn't had any activity for a while. To keep things tidy, I am going to close this issue for now. If you think your issue is still relevant, just leave a comment and I will reopen it. (Read more at #912) Thanks! |
Is this still the case? Why not use the Couldn't |
Your question
Is it possible to invalidate a user after they create an account/login?
What are you trying to do
I'm using next-auth with JWT.
Example:
A user is logged into application with facebook. We delete/suspend the account from database. But the user is still loggedin to the application and jwt token is still valid. Is there a way to invalidate the user login and JWT token?
Feedback
Documentation refers to searching through online documentation, code comments and issue history. The example project refers to next-auth-example.
The text was updated successfully, but these errors were encountered: