Can NextAuth only allow certain users in (like a whitelist)? #4991
-
Right now, if I use the Google provider, for example, anyone with a valid Google account can get authorized with NextAuth. Is there a callback or hook or event or something in NextAuth I can use to compare the account with a whitelist or something in a database to only allow certain users in? I've googled this and looked at a ton of examples and tutorials online, but can't find any example of this yet. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I have found a solution that works for me: callbacks (https://next-auth.js.org/configuration/callbacks). by implementing the signIn callback, i can check the db for the user first, and return true or false to let them in or not. |
Beta Was this translation helpful? Give feedback.
I have found a solution that works for me: callbacks (https://next-auth.js.org/configuration/callbacks). by implementing the signIn callback, i can check the db for the user first, and return true or false to let them in or not.