You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am encountering an issue when implementing the "reset password" flow that can be described in the supabase documentation here.
The first part about sending the reset password email works fine.
The issue happens when the user clicks on the link and is redirected to the change password page : he is redirected to the login page.
As described in the documentation, the "change password" page is protected to only allow authenticated users. Thus, I added a middleware. However, It seems that the user is not yet connected when redirected to this page and is then redirected to the login page.
I tried every thing I saw online but nothing worked. I tried several thing : use the supabase.auth.exchangeCodeForSession(code) method, but that produces a both auth code and code verifier should be non-empty error message.
Expected result
I click on the reset password button
I receive the mail & click on it
I should be logged in and arrive on the change password page
System information
OS: [ Windows 11 ]
Browser : Google Chrome
Version of supabase-js: [e.g. 6.0.2]
Version of Node.js: 20.12.2I am
Additional context
I am using Nuxt 3
The text was updated successfully, but these errors were encountered:
I am experiencing the same issue, but I am using Next.js 14.2.3. The behavior is identical: the user gets redirected to the login page instead of the change password page after clicking the reset password link. Any solutions or workarounds would be greatly appreciated.
Apparently, Nuxt's middleware is ran 2 times : first during the server side rendering and a second time during the hydration process (client side)
By logging, I noticed that the user is not connected in the server side middleware but it is in the client side.
As a workaround, I added a return statement in my middleware when running server side like so :
export default defineNuxtRouteMiddleware(async () => {
if (import.meta.server) return
const user = useSupabaseUser()
if (!user.value) {
const localePath = useLocalePath()
return await navigateTo(localePath('login'))
}
})
I believe you should be able to do the same thing using Next.js
But that is not ideal : you would prefer to be connected server side, since this workaround allows the user to have a glimpse at the page during its loading time but i have no idea how & no answer to this issue so far.
Bug report
Describe the bug
I am using Nuxt 3.
I am encountering an issue when implementing the "reset password" flow that can be described in the supabase documentation here.
The first part about sending the reset password email works fine.
The issue happens when the user clicks on the link and is redirected to the change password page : he is redirected to the login page.
As described in the documentation, the "change password" page is protected to only allow authenticated users. Thus, I added a middleware. However, It seems that the user is not yet connected when redirected to this page and is then redirected to the login page.
Here is my middleware :
==> If I try to log the user using a
console.log
, the output isnull
Here is my supabaseClient :
I tried every thing I saw online but nothing worked. I tried several thing : use the
supabase.auth.exchangeCodeForSession(code)
method, but that produces aboth auth code and code verifier should be non-empty
error message.Expected result
I click on the reset password button
I receive the mail & click on it
I should be logged in and arrive on the change password page
System information
Additional context
I am using Nuxt 3
The text was updated successfully, but these errors were encountered: