How to implement invite-only registration flow with better-auth?
Hello, I'm looking for some help on how to implement this use-case.
Here is the general user creation/registration flow I want to implement:
I've tried using magic links, but I got stuck on how to then add a credentials account to the user.
Magic link also doesn't handle the user's role, but I can manage with setting it up later.
Here is another alternative I've considered, and I'd appreciate some feedback on whether it should work and if it's a good way to do that.
Use the admin API to add users and then send them a "forgot password" link with a custom message. This will then redirect them to reset the password.
Any thoughts?
Here is the general user creation/registration flow I want to implement:
- Existing admin user adds a new user by entering their email (and possibly name and role).
- The new user receives email with a welcome message and a link (time limited) to complete account setup.
- After clicking the link, the user is redirected to a page where they can enter a password and/or link their social account.
- User is redirected to the app's main page.
- Future logins for the user will be done using their password or social account.
I've tried using magic links, but I got stuck on how to then add a credentials account to the user.
Magic link also doesn't handle the user's role, but I can manage with setting it up later.
Here is another alternative I've considered, and I'd appreciate some feedback on whether it should work and if it's a good way to do that.
Use the admin API to add users and then send them a "forgot password" link with a custom message. This will then redirect them to reset the password.
Any thoughts?
Solution
we'll have
sendInvite functionality in the admin plugin soon but magic link or forgot password for the time being should work fine