Built-in invite-only authentication in NextAuth #4106
Replies: 7 comments 4 replies
-
I was wondering the same on this discussion #4132 maybe there is not enough people to push this |
Beta Was this translation helpful? Give feedback.
-
+1 on this, would be really useful |
Beta Was this translation helpful? Give feedback.
-
Check my comment above, I have uploaded a workaround that works for me
On Wed, 14 Sep 2022 at 5:55 PM, Jesse Winton ***@***.***> wrote:
+1 on this, would be really useful
—
Reply to this email directly, view it on GitHub
<#4106 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABUO65RGCQ4UFV3PLZDQYW3V6HRNZANCNFSM55BHLNSQ>
.
You are receiving this because you commented.Message ID:
***@***.***>
--
Regards, Dimitrios Filippou
Lead Software Engineer at Asian Logic
LinkedIn <https://www.linkedin.com/in/dimitrios-filippou-98a703131/> |
Website <https://jimfilippou.github.io> | GitHub
<https://github.com/jimfilippou>
|
Beta Was this translation helpful? Give feedback.
-
Per my original issue/discussion, I am very willing to help implment but I need someone with more experience to lead the api design aspect. @jimfilippou thank you for mentioning the other issue with your solution though, that is very helpful. |
Beta Was this translation helpful? Give feedback.
-
i've managed to hack something together using the 'email' provider. https://gist.github.com/magicspon/614a780d567a08334831347338a3d262 the key is to overwrite the sendVerificationRequest function, and use an api route as the callback url. |
Beta Was this translation helpful? Give feedback.
-
This would be a really great feature if invite-only authentication model was natively supported in next-auth. |
Beta Was this translation helpful? Give feedback.
-
I am adding my two pence: I want to do an invite-only sign-up with OAuth/OIDC, where I do not know the id of the signup in advance, i.e. some existing user can generate a magic key/link and send it out via WhatsApp, not knowing what the invited user's OpenID would be. I think I could implement this easily, if I would have access to the request triggering the Does someone have a hint, where in the code I need to look to transfer the request information through to the signIn callback? Then I would try it out and prepare a PR if it works as expected. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Description 📓
Currently, I am building an app which requires users to have entered a verification code in order to have full access to the app. While this isn't going to be a public facing service, Invite only services (otherwise known as FOMO services) have become somewhat common. I think that this could be a useful feature for NextAuth.
Implementation
For starters, this would require a database in order to store invites.
I think that it would be best implemented as a series of strategies, similar to the
callbacks
option that currently exists. The two main strategies I can think of are code-based invitations and email-based invitations. Code based invitations would basically store invite codes in a database table, and the dev would define the behavior. The other option is email based invitations; a database table would store a series of allowed emails. When a user with that email signs up for the first time, that invite becomes invalid. In both of these, the dev is responsible for implementing some amount of logic. Where does NextAuth come in? NextAuth would effectively be responsible for enforcing the policies. For example, users that sign in but are not invited would be redirected by NextAuth to either a code-entry page or some informational/error page. This would also be interesting if NextAuth ever implements aPhoneProvider
in the future.I don't plan on implementing this by myself; however, if someone else is interested, I would gladly work with them to help implement this.
How to reproduce ☕️
I guess this is a good place to put it?
But basically here's one of the checks I perform in the app that I am building:
There are also other client side checks which redirect users.
Psuedo-implementation example
Contributing 🙌🏽
Yes, I am willing to help implement this feature in a PR
Beta Was this translation helpful? Give feedback.
All reactions