-
Notifications
You must be signed in to change notification settings - Fork 1
Description
Signed out users who fill out the forgot password form get sent a Supabase auth email with a link to reset their password. But that link doesn’t work. It instead redirects them to sign in, which they obviously can’t do because they don’t know their current password.
Specifically, they get sent the email_action_type === "recovery" auth email with a link that looks something like this:
`${supabase_url}/auth/v1/verify?token=${token_hash}&type=${email_action_type}&redirect_to=${redirect_to}`That unfurls to something like:
https://abc123.supabase.co/auth/v1/verify?token=pkce_abcdef12345&type=recovery&redirect_to=https://www.peels.app/auth/callback?redirect_to=/profile/reset-password
Which ultimately lands at:
https://www.peels.app/sign-in?redirect_to=%2Fprofile%2Freset-password
This redirect is almost definitely because /profile/reset-password, being in profile is a protected route and the token doesn’t seem to give them the temporary access that it should.
Note that a very similar bug occurs with email_action_type === "magiclink", which should also automatically sign the user in. It might also occur with the unused "invite" and "reauthentication" types, which have similar purposes.
That auth link is exposed in supabase/functions/_templates/reset-password-email.tsx, since we’re using custom auth emails via React Email and Resend. That’s the standard URL format for pretty much all of the Supabase auth emails, as you can see in the above docs link and elsewhere. So I don’t think the issue lies there.
I believe issue existed before I made the custom auth emails, so the problem may lie in how we handle redirects and/or protected routes. I.e. in src/utils/supabase/middleware.ts.