auth-js icon indicating copy to clipboard operation
auth-js copied to clipboard

How user can recover password if user is authenticate with phone number?

Open Rayyanmaq1 opened this issue 2 years ago • 3 comments

I have authenticate user from phone number and password now I'm facing a issue that I can't recover password if user have forgotten it.

Rayyanmaq1 avatar Oct 13 '21 07:10 Rayyanmaq1

Thanks for raising this up @Rayyanmaq1, we should create a function on gotrue-js to handle password resets for phone and password signups.

Currently, a workaround for this would be to use the signIn({phone}) method which will send an otp to the user's phone number. From there, you can use the verifyOTP method to verify the otp and sign the user in.

Once the user is signed in, they can reset their password by updating it via the updateUser endpoint

kangmingtay avatar Feb 10 '22 14:02 kangmingtay

I know this but if user is authenticated with phone number and password if he want to reset the password how he can do it.

Rayyanmaq1 avatar Feb 10 '22 14:02 Rayyanmaq1

Could you elaborate more on what you mean by "reset the password" please?

A password reset is the same as updating the password once the user is authenticated. If the user has forgotten the password, then the only way to authenticate the user is via an otp. The user has to be authenticated first before they can change the password.

kangmingtay avatar Feb 10 '22 15:02 kangmingtay

Hey @Rayyanmaq1, please let us know if you're still facing this problem, as mentioned, if you wish to reset a user's password through a phone number, these are the following steps:

  1. Sign-in the user with phone OTP
  2. Redirect the user to a reset password page
  3. Call the update method or updateUser (if you're using v2) to update the user's password.

kangmingtay avatar Sep 30 '22 06:09 kangmingtay