I was wondering if you guys could show me how to setup Reset Password in Swift, I am currently using Firebase as my backend service. I just need the code.
To send a password reset email to user, on the Users page, hover over the user and click ... > Reset password. The user will receive an email with instructions on how to reset their password.
One way to allow your users to change their password is to show a dialog where they enter their current password and the new password they'd like. You then sign in (or re-authenticate) the user with the current passwordand call updatePassword() to update it.
Finding the Password Hash Parameters To access these parameters, navigate to the 'Users' tab of the 'Authentication' section in the Firebase Console and select 'Password Hash Parameters' from the drop down in the upper-right hand corner of the users table.
The answer is in the API documentation:
-sendPasswordResetWithEmail:completion:
Initiates a password reset for the given email address.
See FIRAuthErrors for a list of error codes that are common to all API methods.
In Swift 3.x and Firebase 3.x it will look like this:
FIRAuth.auth()?.sendPasswordReset(withEmail: "email@email") { error in
// Your code here
}
Edit:
Firebase 4 changed the Firebase functions to be more aligned with the naming conventions in Swift.
Auth.auth().sendPasswordReset(withEmail: "email@email") { error in
// Your code here
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With