I want only registered users to be allowed to login & only admin can register new users? (Next-Auth)
I don't want users to sign up themselves. I first need to check something manually, only then do i want to send them a sign-in link. I do know how to prevent anyone from logging in:
However, I now want a functionality for myself / for our backend, where I can put in the users email address and they'll get a sign-in link. Not sure how I would do that. So basically, only already registered users should be allowed to sign-in, but registration should only be up to me or an admin.
14 Replies
You could make a admin page with a mutation that would create the user entry, and then use whatever email service to send them an email to the site.
Ps: you can't findunique with email it must be id
why not? are u sure? it's working for me so far
Okay
Not getting your point
Then don't put a registration page then
I dont have one
but sign-in by default in next-auth registers the user
What you should be doing is have like an admin dashboard
yeah exactly
but I am not sure how to create the users for next-auth from my admin dashboard.
can i just create a user with prisma, add them to the db and then next-auth will pick up on that?
or will i need to go through the next-auth flow, because its creating other things in the background
To create a user you will need the email and whatever you require
So the flow is still there
But this time the flow will be on the admin dashboard
but it stills goes through next-auth, right?
How do I trigger this then, as my admin dashboard will be on a different domain
sorry i think i'm a bit stuck, it's probably super obvious
Is it a credentials based system?
Next auth is usually for sign in
To create a row its a function outside
Been on a different domain doesn't mean anything
You can still use same database
yeah true
but i am using email magic links
so next-auth will use whatever domain i am on
to send the link, i think
Never used that
But i think you can use the signIn function provided by next auth on the admin front-end to do all you need
ok i'll try that!
thanks a lot
👍