3

I'm facing an issue updating a password for a supabase user on a BlitzJs (NextJs) project.

Basically, I have a reset password method that works perfectly. First I send an email with a reset link, that opens a page where the user can update his password like so:

const { error, data } = await supabase.auth.api.updateUser(token, { password: password.trim() })

the token being the one in the url, provided in the email link.

So far, so good, but when I try to update the password for a logged in user, using the exact same method supabase.auth.api.updateUser, it fails to find the user; The difference is the token is the session.access_token

So I've tried to use the supabase.auth.api.updateUserById method, but it gives me another error: { message: 'User not allowed', status: 401 }

Any ideas? I feel the supabase docs about this is not very clear, and probably outdated as it doesn't show all the available methods :/

Manu
  • 372
  • 2
  • 12

1 Answers1

0

Update password for authenticated user.

const { user, error } = await supabase.auth.update({password: 'new password'})

For more informations check: Supabase references