Hey guys! I'm facing an issue updating a password ...
# help
m
Hey guys! I'm facing an issue updating a password on 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:
Copy code
js
const { error, data } = await supabase.auth.api.updateUser(token, { password: password.trim() })
the token being the one in the url. This works, 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 docs about this is not very clear, and probably outdated as it doesn't show all the available methods :/
n
Hello ! This thread has been automatically created from your message in a ``few seconds ago``. Pinging @User so that they see this as well! 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.
m
I think I figured out why this happened: updateUser or updateUserById are "admin" functions, that requires to use the role_service_key. I solved my problem using the simple supabase.auth.update function
n
Thread was archived by . Anyone can send a message to unarchive it.
manuelcoffin (2022-03-21)