1
votes

My app currently allows a user to create their Firebase account via phone number. I'm currently trying to figure out the logic for a password reset when the user created their account with a phone number rather than email.

The only reset password functionality i can find on the Firebase docs requires an email address.

Any help is appreciated!

1
I don't think there is a password that a user is supposed to remember for phone auth. So no password reset is needed or possible. - Christopher Moore
After Christopher's comment, I realized passwords aren't necessary when using phone auth, so i took out the functionality altogether - Justin Frazer

1 Answers

1
votes

You can use verifyPhoneNumber:UIDelegate:completion: to send the users another SMS message for verification and then sign in using the verificationID.

Official doc on how to do that -> https://firebase.google.com/docs/auth/ios/phone-auth#send-a-verification-code-to-the-users-phone.

PhoneAuthProvider.provider().verifyPhoneNumber(phoneNumber, uiDelegate: nil) { (verificationID, error) in
  if let error = error {
    self.showMessagePrompt(error.localizedDescription)
    return
  }
  // Sign in using the verificationID and the code sent to the user
  // ...
}

OR

If you have a server, you can use Firebase admin SDK, available in Node.js, Java, Python, Go, and C#, to update the user's password property just with user's uid.

Example in Node.js:

admin.auth().updateUser(uid, {
  password: "YOUR_NEW_PWD"
})
  .then((userRecord) => {
    console.log('Successfully updated user', userRecord.toJSON());
  })
  .catch((error) => {
    console.log('Error updating user:', error);
  });