supabase-js: Enabling Post-Signup Email Verification without Blocking User Sign-In on Supabase (Resend)
Bug report
- I confirm this is a bug with Supabase, not with my own application.
- I confirm I have searched the Docs, GitHub Discussions, and Discord.
Describe the bug
I am trying to improve the user experience in my application by allowing users to sign in immediately after registration, even before verifying their email. The default behavior in Supabase requires users to verify their email before they can sign in, which I believe creates a poor user experience. I want to give users the ability to verify their email after they have signed in by sending them a verification link or preferably a code to verify their email. However, I’m facing an issue where I cannot send a verification link to users using the Supabase Auth resend method for this purpose.
To Reproduce
Steps to reproduce the behavior, please provide code snippets or a repository:
- Initialize Supabase auth with a user’s email and password.
- Try to send the user a verification email after sign-up (not blocking sign-in) using the
resendmethod as follows:await supabase.auth.resend({ email: user?.email as string, type: "signup" }); - Notice that no verification email is received.
Expected behavior
I expect to be able to send users a verification email (or ideally a verification code) after they have signed up and signed in, without blocking their initial sign-in due to unverified email. This approach aims to enhance the user experience by not forcing email verification before the user can explore the application.
Additional context
This issue is critical for user onboarding and directly impacts the user experience in our application. If there’s an alternative approach to achieve this behavior or if someone has solved a similar issue, insights would be greatly appreciated. Ideally, I would like to send a verification code that users can enter to verify their email, but currently, the primary issue is the inability to resend the verification link after the user signs in.
About this issue
- Original URL
- State: open
- Created 3 years ago
- Reactions: 13
- Comments: 20
It’s crazy that this isn’t supported — a fundamental feature for good UX. You want the user to access parts of your app before verifying the email (as an example).
Absolutely agreed.
I did not think to check that this was an option before completely designing my project around Supabase Auth, as it is a feature that the majority of modern, consumer-facing services implement.
A bit frustrating to have to find a workaround to this, particularly having paid for Supabase Pro…
Anyone have suggestions on how to maybe approach this without risking potential spam from bots on account signups?
And then, of course, how to handle what essentially amounts to having to recreate a portion of the auth architecture (handling email templates, email sending, token generation and verification, middleware adjustments, etc)…?
Maybe forcing (or strongly encouraging) OAuth signups is the best way forward to get around the reduced onboarding user experience…
May I ask if there’s any updates to this? This flow is also very crucial to us, as we do not want verification to block the user onboarding process.
So what we want to achieve is that - upon signup, no verification is needed, and the user could go through onboarding as needed. After 1hr of sign up, we check for whether the email is verified, and if still not verified, we then block the site access to prompt the user to verify first.
I have the same issue. Verifying the email after signup is a pretty common thing which is currently not really possible. Any updates on that topic?
+1 to this feature request, would help a lot in onboarding experience
Where is this option?
I am also interested in a way to enable post-signup verification. While a custom backend (using
supabase.auth.adminon the server side + custom metadata) should help develop an alternative solution, I was wondering whether there can be built-in support for this problem without major changes.A few observations:
config.Mailer keeps track of 2 booleans of interest:
AutoconfirmandAllowUnverifiedEmailSignIns(Note that the default value ofAllowUnverifiedEmailSignInsis False).The “Confirm email” switch corresponds to
Autoconfirm(as seen in the screenshot below). But I don’t see any way to controlAllowUnverifiedEmailSignInsfrom the GUI.While /signup (For email-based signups) makes use of
Autoconfirmfor deciding whether to mark the user’s email as verified or not, /token?grant_type=password (For email & password-based sign-ins) is not making use ofAllowUnverifiedEmailSignInsfor deciding whether to let user sign in with the given credentials.At the moment,
AllowUnverifiedEmailSignInsis only being used in the case of external identity providers (Apple/GitHub/Facebook, etc).With this, I think it would be great to allow devs to configure
AllowUnverifiedEmailSignInsfrom the dashboard, and use its value for email & password-based sign-ins. I believe doing this (along with potentially making slight tweaks in the sign-up API as well) should address the issue.I believe you have set
Confirm email: Users will need to confirm their email address before signing in for the first time.tofalse. If that is the case, the user email is considered “verified” (you can confirm this by looking at theuser.email_confirmed_atfield. It is null when the email has not been verified and has some value when it is. Any user that registered when theConfirm emailsetting was set to off, will have theiremail_confirmed_atvalue close to thecreated_attimestamp.If you want to implement “mail verification post sign-up” I would recommend using a custom
metadataattribute (maybe a key likeemail_verified) which can be true/false depending on whether the mail is verified or not. But then you would have to implement your email verification API (whose responsibility would be to keep track of the verification tokens and setemail_verifiedto true).Edit: For reference, this is how Supabase’s
resendAPI works: https://github.com/supabase/auth/blob/master/internal/api/resend.go#L64-L172