Supabase sends OTP and Magic Links at the same time!

Supabase sends OTP and Magic Links at the same time, when i try to sign in using signInWithOtp(), sometimes it sends me an otp code, and sometimes it sends magic links, how can i force it to only send otp codes?
36 Replies
inder
inder5d ago
You mean in the email you receive sometimes there is an otp and sometimes signin link? or are you receiving 2 emails?
Yassin M.
Yassin M.OP5d ago
Yes, exactly
inder
inder5d ago
This depends on how you've configured Confirm Email setting https://supabase.com/dashboard/project/_/auth/providers For example: - If its a new user and you've Confirm Email turned on, then Confirmation email template will be sent - if you've Confirm Email turned off, then even for new user Magic Link email template will be sent So in your case, I believe in either confirm email template or magic link template you've added {{.Token}} field and not in the other template
No description
Yassin M.
Yassin M.OP5d ago
No description
No description
inder
inder5d ago
And in magic link template?
Yassin M.
Yassin M.OP5d ago
No description
inder
inder5d ago
Yeah, this is why you face this issue. You need to add {{.Token}} here as well
Yassin M.
Yassin M.OP5d ago
Great!
Yassin M.
Yassin M.OP5d ago
It is sending the otp code, but it is also saying "Your Magic Link" as the title of the email, how can i fix that?
No description
inder
inder5d ago
This looks like a gmail thing. All these messages seem to be in same thread. And its taking the title of the first email in the thread. Delete all these emails and retry signup. i believe that should show the correct title
Yassin M.
Yassin M.OP5d ago
I deleted them all, but still giving the same title
No description
No description
inder
inder5d ago
Thats odd. In this screenshot, the subject is set to Confirm Your signup. Let me test it on my end
Yassin M.
Yassin M.OP5d ago
Okay
inder
inder5d ago
I'm receiving the correct subject
No description
inder
inder5d ago
Try making some changes in the confirmation email subject and click on save.
Yassin M.
Yassin M.OP5d ago
Hmm, that's strange Okay It worked!
inder
inder5d ago
Could be some cache issue.
Yassin M.
Yassin M.OP5d ago
Yes maybe, i've got another issue in verifying the otp code When i enter the sent otp code, it says "Token has expired or is invalid", with a status code of "403"
inder
inder5d ago
Share the verifyOtp code
Yassin M.
Yassin M.OP5d ago
111302
inder
inder5d ago
no I mean the actual code you have in your app not the otp
Yassin M.
Yassin M.OP5d ago
Okey!
Yassin M.
Yassin M.OP5d ago
No description
Yassin M.
Yassin M.OP5d ago
No description
inder
inder5d ago
Are you sure that you're passing the correct email and token values in function?
Yassin M.
Yassin M.OP5d ago
Yes, i'll record a video to you
inder
inder5d ago
Try console logging the values of email and token
Yassin M.
Yassin M.OP5d ago
I did
inder
inder5d ago
please create a minimal github repo
Yassin M.
Yassin M.OP5d ago
No description
inder
inder5d ago
Are you sure there isn't some space around the token? In your function try this token: token.trim(),
Yassin M.
Yassin M.OP5d ago
same thing
No description
Yassin M.
Yassin M.OP5d ago
Email: yassinmashaly55@gmail.com | OTP: 659488
No description
inder
inder5d ago
. Also just to be sure these are previous logs right? because in the video otp you entered is different
Yassin M.
Yassin M.OP5d ago
Yes Problem solved, there was a conflict in my side! Thanks @inder
inder
inder5d ago
happy to hear you got it working!

Did you find this page helpful?