register limited people
hey, im working on a project that only allow few invited people to register and then use my website.
is there a way to do that? thanks in advance
11 Replies
No official way but logically yes
You can create a table and seed it with the invite list unique id such as email or username as the case maybe
Then in the sign up procedure query the database and get the list then check if the email or username is on the list
Then throw an error if the email /username provided isn't on the list gotten from your 1st query
Let's say I only use Google and magic link is there a way to just configure it through google console?
?
What exactly is the goal? Allow X number of people to register? Allow people with a code to register? Allow only certain people (by say email) to register?
Lopen32 covered the last one. If you're trying to do that then no, there is no way to do that through the Google console.
You could only allow certain emails (up to 100) if you leave your oauth setup as private or testing or whatever its called on Google's end. However that's a bad idea for a number of reasons and you shouldn't do that.
i need certain people to register, let say only 10 of my friend that can only use my web app
Lopen has given you the answer.
@Devastated if you want a more detailed overview of how to implement it, check out callbacks: https://next-auth.js.org/configuration/options#callbacks and events: https://next-auth.js.org/configuration/options#events
Options | NextAuth.js
Environment Variables
ill check it out thankss
so i use the callback signIn and from that i call prisma to retrieve the whitelist email?
Yeah, probably
Or use the createUser event
can you explain about the createUser event cause the docs does explain it that much
I've never used it, put some console.log and test it for yourself - that's the best method imo haha
Lek ok thanks for the reference tho