Update password (not reset password page)
Hi everyone đź‘‹
I'm working on a password update feature using Supabase Auth in my Next.js app.
The password update itself works perfectly — Supabase updates the password and I can log in again with the new one.
However, the current session becomes invalid right after the password change, but Supabase doesn't automatically sign out the user. So on the frontend, the user still appears logged in, but any API calls fail with “Invalid JWT”.
I’ve tried calling supabase.auth.signOut() or refreshing the session after the update, but it doesn’t seem to take effect — the button stays on “Updating...” and the session event log still shows “Session active”.
How can I properly handle this situation and force a clean logout (or session refresh) right after a successful password update?
Thanks a lot for your help 🙏

9 Replies
Hey!
we have found the solution, I have change this line :
supabase.auth.updateUser({
password: formData.newPassword,
});
Before, I only get the error from the response.
Now, the update password work and the user is redirect on the login page
Awesome, glad you got it working!
Just to clarify for anyone else who might have this issue - so the problem was that you weren't destructuring the full response from updateUser() function?
You changed this line:
const { error } = await supabase.auth.updateUser(...)
to:
{ data, error } = ...
to get data as well?
Did you by chance also add:
await supabase.auth.signOut();
to the now working code? Or is it working without it?From what I understand, supabase automatically invalidates the session so I had to redirect to the login page. I tried putting signOut but it didn't work (in fact, I tried a lot of things lol). With a setTimeOut and a message to the user, I manually redirect to the login page.
Ah i see. As long as you got it working. Let us know if you run into any other issues. Happy coding! au revoir!
Thanks
Hey, if you do not mind, can I have a look at the updated same "onSubmit" that now works just to gain a better understanding?
I have a fully working example repo here with this auth flow https://github.com/silentworks/supabase-by-example/tree/main/nextjs
