hi friends, i have tried to reset my password and ...
# help
l
hi friends, i have tried to reset my password and got the password recovery email..
Copy code
await supabase.auth.api.resetPasswordForEmail(email, {
          redirectTo: `${window.location.origin}/reset-password`,
        });
Copy code
https://xxx.supabase.co/auth/v1/verify?token=fvtgjvsxjajktseuqshp&type=recovery&redirect_to=http://localhost:3000/reset-password
when i checked the link, it has the token but when it redirects to my page, the url only has a single hash.. without the token, i can't update my user's password.. This is on nextjs any idea what could be the issue?
n
Hello @lanbau! This thread has been automatically created from your message in #843999948717555735 a few seconds ago. We have already mentioned the @User so that they can see your message and help you as soon as possible! Want to unsubscribe from this thread? Right-click the thread in Discord (or use the ``...`` menu) and select "Leave Thread" to unsubscribe from future updates. Want to change the title? Use the ``/title`` command! We have solved your problem? Click the button below to archive it.
j
n
lanbau (2022-05-22)
j
But basically, the reset link acts as a 'magic link', where essentially the user is signed in once they click on the link. If you have an onAuthStateChange() listener somewhere, it will first show a 'SIGNED_IN' event, and then a 'PASSWORD_RECOVERY' event.
A basic outline of the password reset flow would be to
1. Listen for the Password_Recovery event 2. Redirect (using Router.push()) to whatever directory you have your pw reset form on 3. Input/Validate the new password 4. Update the user's account through supabase.auth.api.updateUser({password: 'new-password'})
You do not need to provide the access_token manually as in the docs because it will be provided automatically since the user is already signed in
l
thanks for the 4th step, it didn't work for me.. it keeps returning bearer token required or something. the below function worked instead.. took me hours to figure out
Copy code
const { data, error } = await supabase.auth.update({
        password,
      });
😆