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
Lopen
Lopen17mo ago
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
arete
arete17mo ago
Let's say I only use Google and magic link is there a way to just configure it through google console? ?
royanger
royanger17mo ago
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.
arete
arete17mo ago
i need certain people to register, let say only 10 of my friend that can only use my web app
royanger
royanger17mo ago
Lopen has given you the answer.
Piotrek
Piotrek17mo ago
@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
arete
arete17mo ago
ill check it out thankss so i use the callback signIn and from that i call prisma to retrieve the whitelist email?
Piotrek
Piotrek17mo ago
Yeah, probably Or use the createUser event
arete
arete17mo ago
can you explain about the createUser event cause the docs does explain it that much
Piotrek
Piotrek17mo ago
I've never used it, put some console.log and test it for yourself - that's the best method imo haha
arete
arete17mo ago
Lek ok thanks for the reference tho