You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
auth.signIn() with magic link creates users in Auth.users table #1176
If the email provided is not in Auth.users table it shouldn't be created and an error should be thrown.
Yeah, as @edgarasben points out, there are plenty of apps that use "magic signin" - i.e. the user never creates a password. So this is expected behaviour. I'll keep this open for a few days if there are comments or suggested improvements
Just a spontanous thought - but how about defining the behaviour of the magic link based on, if signup is enabled/disabled in the backend?
if signup is disabled: The admin probably wants to create/invite user on their own, so when an unknown email is entered the request could be ignored
if signup is enabled: The admin probably wants to let users create their account on their own so when an unknown email is entered it could be created in the backend
I think there could be an option here.
If you input email that does not exist yet, you get an error:
This looks nice, but maybe on a security perspective, you don't want to show the message that the account couldn't be found - so attackers could somehow pinpoint which emails have already been registered?. Personally, I'd just display a message like "An email has been sent to your inbox"
Reacted by Nicholas Chiang, richcorbs, Mikilll94 and Pawel
Disabling the registration and inviting people manually as you say could be a nice option too. (Log in only).
I was talking more about having some way to separate sign up and log in, while still relying on magic link tech technique. I expect some people might be confused about what's happening with signin only. Am I creating an account? Am I logging in?
But good point about the security. You could add "If your account exists, an email will be sent to your inbox".
Unlike password reset and email verification, the email used does not necessarily need to belong to an existing user, as this operation can be used to sign up new users into your app via email link.
I think that Supabase should continue to mimic that ☝️ behavior to make it easier and more intuitive for users (like me) who are migrating from Firebase to Supabase.
I do agree with @pichichi91 that manual invites might be a common enough use-case. But I think a better solution (instead of changing the current signup/login behavior of the magic link) would be a "test mode" similar to Google OAuth2 where you have to manually specify "test user email addresses" that are allowed to login or signup at all:
Since this is left open for opinions, I'll add mine.
I think it's awesome that magic links has streamlined the signup/login paths into a single flow. It is also in-line with how the OAuth providers work. It's much cleaner and simpler.
I can see how some users might be a bit perplexed, but if there is only one "sign in" page, seems like they will get it soon enough :)
Also, I noticed that using a magic link for a new user signup will send the "confirmation" email template, while using a magic link for an existing user will send the "magic link" template. So, you can customize these email templates to help the user understand whether they have created an account or just logged in.
Automatic signup with magic link is nice, but it should only be available via supabase.auth.signUp()
If there is a typo in the email entered by the user when signin in, he still receives a confirmation message, but will not receive the magic link since it has been sent to an invalid email.
Reacted by Edgaras Benediktavicius, richcorbs, Fabian Morón Zirfas, ulisses-cruz, Kris Gunnars, Gareth Simons, Tyler Adams, Mike Peiman, Christian Butcher, David Lorenz and 6 more
I wanted to implement this but I am getting a typescript error when I try to add the "create_user" flag to my signIn function:
"Argument of type '{ email: string; create_user: boolean; }' is not assignable to parameter of type 'UserCredentials'.
Object literal may only specify known properties, and 'create_user' does not exist in type 'UserCredentials'.ts(2345)"
yeah this is because the gotrue version that your supabase project is currently on is not updated to the latest one yet, we'll be rolling out the updates to all existing projects soon!
yeah this is because the gotrue version that your supabase project is currently on is not updated to the latest one yet, we'll be rolling out the updates to all existing projects soon!
Creating the user is fine in my case, but how can we tell if it's a new user and therefore the magic link has type=signup, or if it's an existing user and the link has type=magiclink?
The email message says to click the link or "Alternatively, enter the code", so I guess I also need to show an input box for the user to manually enter the code if they so choose, calling GET /verify that requires the right type.
Creating the user is fine in my case, but how can we tell if it's a new user and therefore the magic link has type=signup, or if it's an existing user and the link has type=magiclink?
The email message says to click the link or "Alternatively, enter the code", so I guess I also need to show an input box for the user to manually enter the code if they so choose, calling GET /verify that requires the right type.
Hmm let me check on this. We recently merged a PR that would send both the confirmation link and token to the user's email. But you can also modify the email template to only send the email link.
Thanks @kangmingtay. It is possible to modify the magic link template email so it's not a big deal. I could also call generateLink() and send the email myself. From what I can see generateLink returns an object that will have an email_confirmed_at field only if the user already exists.
I've just been trying this with phone login, and unfortunately, when set to true, this returns the error 'signups not allowed for otp' even for an account which already exists (and preventing the login from proceeding):
If I set it to shouldCreateUser to true and make no other changes, the login process continues as normal. Unfortunately, this also means that accounts are still created (if they don't exist) when using signIn.
This is when using the library "@supabase/supabase-js": "^1.33.3".
Activity
edgarasben commentedon Apr 20, 2021
I think this could be an option. Some apps might want a magic sign-up/log-in while others might only want a magic log-in.
kiwicopple commentedon Apr 20, 2021
Yeah, as @edgarasben points out, there are plenty of apps that use "magic signin" - i.e. the user never creates a password. So this is expected behaviour. I'll keep this open for a few days if there are comments or suggested improvements
suilillo commentedon Apr 20, 2021
I would suggest to explain this in documentation to avoid confusion.
Thanks!
edgarasben commentedon May 14, 2021
I think there could be an option here.
If you see the way magic.link works, they have both - log in and sign up pages.
If you input email that does not exist yet, you get an error:

pichichi91 commentedon May 17, 2021
Just a spontanous thought - but how about defining the behaviour of the magic link based on, if signup is enabled/disabled in the backend?
This looks nice, but maybe on a security perspective, you don't want to show the message that the account couldn't be found - so attackers could somehow pinpoint which emails have already been registered?. Personally, I'd just display a message like "An email has been sent to your inbox"
edgarasben commentedon May 17, 2021
Disabling the registration and inviting people manually as you say could be a nice option too. (Log in only).
I was talking more about having some way to separate sign up and log in, while still relying on magic link tech technique. I expect some people might be confused about what's happening with signin only. Am I creating an account? Am I logging in?
But good point about the security. You could add "If your account exists, an email will be sent to your inbox".
nicholaschiang commentedon May 26, 2021
The current behavior mimics the behavior of Firebase Authentication which has both seamless sign-up (when a user doesn't exist) and login via email links. From the Firebase Authentication docs (see also this magic link login/signup guide):
I think that Supabase should continue to mimic that ☝️ behavior to make it easier and more intuitive for users (like me) who are migrating from Firebase to Supabase.
I do agree with @pichichi91 that manual invites might be a common enough use-case. But I think a better solution (instead of changing the current signup/login behavior of the magic link) would be a "test mode" similar to Google OAuth2 where you have to manually specify "test user email addresses" that are allowed to login or signup at all:
rsdavis commentedon Jun 21, 2021
Since this is left open for opinions, I'll add mine.
I think it's awesome that magic links has streamlined the signup/login paths into a single flow. It is also in-line with how the OAuth providers work. It's much cleaner and simpler.
I can see how some users might be a bit perplexed, but if there is only one "sign in" page, seems like they will get it soon enough :)
Also, I noticed that using a magic link for a new user signup will send the "confirmation" email template, while using a magic link for an existing user will send the "magic link" template. So, you can customize these email templates to help the user understand whether they have created an account or just logged in.
CR1AT0RS commentedon Jul 21, 2021
I think we can just add an option called "Disable SignUps" with magic link. I personally like the automatic magic link signup.
oliviermtl commentedon Jul 30, 2021
Automatic signup with magic link is nice, but it should only be available via supabase.auth.signUp()
If there is a typo in the email entered by the user when signin in, he still receives a confirmation message, but will not receive the magic link since it has been sent to an invalid email.
richcorbs commentedon Sep 2, 2021
I like the idea but in practice how would we ever get new users in the system (auth.users) if there wasn't a way to sign them up?
18 remaining items
kristjanmar commentedon Jan 26, 2022
I wanted to implement this but I am getting a typescript error when I try to add the "create_user" flag to my signIn function:
"Argument of type '{ email: string; create_user: boolean; }' is not assignable to parameter of type 'UserCredentials'.
Object literal may only specify known properties, and 'create_user' does not exist in type 'UserCredentials'.ts(2345)"
Here's my code:
kangmingtay commentedon Jan 26, 2022
hey @kristjanmar, we haven't added it to
gotrue-jsyet but will be looking to do so soon!hope this new param helps everyone on this thread to build better magiclink login flows 💪🏻
kristjanmar commentedon Jan 26, 2022
Thanks @kangmingtay -- I managed to get rid of the type error by adding // @ts-ignore above the line.
However, the "create_user: false" flag is not working. When I type an email that is not signed up in the login form, it creates the user in Supabase.
I already updated to the latest version of supabase-js and tested this several times. The user is always created, just like before.
kangmingtay commentedon Jan 26, 2022
yeah this is because the gotrue version that your supabase project is currently on is not updated to the latest one yet, we'll be rolling out the updates to all existing projects soon!
kristjanmar commentedon Jan 26, 2022
That makes sense, thanks for clarifying.
kristjanmar commentedon Feb 11, 2022
I see that supabase/gotrue-js has been updated. Does this mean that the create_user: false flag should work?
kristjanmar commentedon Feb 16, 2022
Any updates on this?
mirkonasato commentedon Feb 20, 2022
Creating the user is fine in my case, but how can we tell if it's a new user and therefore the magic link has
type=signup, or if it's an existing user and the link hastype=magiclink?The email message says to click the link or "Alternatively, enter the code", so I guess I also need to show an input box for the user to manually enter the code if they so choose, calling GET /verify that requires the right
type.kangmingtay commentedon Feb 24, 2022
hey @mirkonasato,
Good point, I've created a PR to address this
Hmm let me check on this. We recently merged a PR that would send both the confirmation link and token to the user's email. But you can also modify the email template to only send the email link.
mirkonasato commentedon Feb 24, 2022
Thanks @kangmingtay. It is possible to modify the magic link template email so it's not a big deal. I could also call generateLink() and send the email myself. From what I can see
generateLinkreturns an object that will have anemail_confirmed_atfield only if the user already exists.kristjanmar commentedon Mar 4, 2022
This is still not working, unfortunately. The user gets added when typing an email into the login form even when the flag is activated.
I've tried shouldCreateUser, create_user and noSignup as the flag, since it is unclear which one it's supposed to be. But none of them work.
chrisb2244 commentedon Apr 4, 2022
@kristjanmar I think you need to put the shouldCreateUser in the second parameter, that is:
ChronSyn commentedon Apr 13, 2022
I've just been trying this with phone login, and unfortunately, when set to
true, this returns the error 'signups not allowed for otp' even for an account which already exists (and preventing the login from proceeding):If I set it to
shouldCreateUsertotrueand make no other changes, the login process continues as normal. Unfortunately, this also means that accounts are still created (if they don't exist) when usingsignIn.This is when using the library
"@supabase/supabase-js": "^1.33.3".kangmingtay commentedon Apr 16, 2022
Hey @ChronSyn, thanks for reporting this with the repro steps. I'll take a look at this soon!