Reset Password flow confusion/not working
I have a supabase/ssr + Remix project set up with the following versions:
I've worked through the sign up and login flows and started to add the reset password flow to my app. I've created singleton objects for the server and browser client, both using
@supabase/ssr
like so:
createServerClient
The email triggers just fine, I'm able to find it in inBucket and I get both the link and the OTP in the email. The (plaintext) email looks like this:
Clicking the link redirects correctly and appends a ?code=
param to the end. This is where I'm stuck - I assumed I should be calling exchangeCodeForSession
with the code
param since it seems to be auto-applied to the redirect, but I end up with the following error:
One thing I did notice was that the email template for Reset Password (in my supabase dashboard, not local) is different than what this flow is offering. So at this point, my question is:
Is the template being sent the wrong template? I would expect the reset password method to send the right URL for the flow. If it is the wrong template/link, how do I modify it to match what I have in my project dashboard?
I found this Github issue with the same error but not much else while looking around on discord/github/stackoverflow: https://github.com/supabase/supabase/issues/19896GitHub
Cannot read properties of null (reading 'split') in exchangeCodeFor...
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 seeing TypeError - Cannot r...
4 Replies
Just an update here
- I figured out how to set up a reset password email locally and have it matching what's in prod
- the
verifyOtp
method works
- the updateUser
method does not work
When calling updateUser
- after going through verifyingOtp and setting a session, I get error: AuthSessionMissingError: Auth session missing!
I was finally able to get this to work by calling setSession
directly before updateUser
Would you be willing to share more of the sign up and login flows you've set up? I've been working on using the new supbase/ssr library to set up a new project and having a challenge at getting it all wired up. This is my first project with both Remix and Supabase, so while most things are normal learning curve, this part (with the new ssr libary and auth) is a big sticking point for me.
I have been successful getting the sign-in, sign-out flow to work. I'll try and share some tips that worked for me, once I've better understood all that I have.
@garyditsch sure thing, I can share samples later tonight or tomorrow
Got delayed because of the holidays. Here's signup and login files I have working right now. I'm omitting some of the imports for brevity's sake.
login.ts
For some reason, I found the Supabase session to be unreliable but Remix sessions work very consistently for me. So I'm just using supabase for the API and then storing everything in the Remix Session. The
getSupabaseWithHeaders
method is in my original post.
Signup action and loader look like this:
The authenticate util just checks if the following exists
If access_token exists, I short circuit and return the token; if there's only a refresh token present, I refresh the session, store it on success and return the access token:
and then otherwise just return a {token: null}
or redirect based on whatever condition I pass inThank you for coming back to this. I have had things mostly working, I will cross reference my work with this to evaluate my choices.