Forgotten Password Flow

Firebase would send user a reset password email with a link which directs the user to a reset password webpage. The default email template is multilingual and customisable. Here are the English and Tradition Chinese versions, respectively:

By setting the languageCode property, you can select which language the email will be sent in to the user. Here is the list of supported languages and some examples:

en — English en_gb — English (UK) zh_tw — Traditional Chinese zh_cn — Simplified Chinese

* Please note that you have to create custom email action handlers to support multilingual email templates after you customise the template content.

Option 1 (Easier) : Using the Firebase Console

Steps for sending reset password email to user

Option 2: Programmatically

Call sendPasswordReset(withEmail: String, callback: AuthResultCallback) to send the user a reset password email. By clicking the link embedded in the email, the user will be directed to the reset password webpage. The default template looks like this:

Default email template for resetting password

Here are the exceptions that might be thrown:

AuthErrorCode.userNotFound — when Firebase cannot find an account with the email address the user specified AuthErrorCode.invalidEmail — the email address is badly formatted, e.g. example@!?!?!?.com AuthErrorCode.invalidRecipientEmail — indicates an invalid recipient email was sent in the request AuthErrorCode.invalidSender — indicates an invalid sender email is set in the console for this action AuthErrorCode.invalidMessagePayLoad — indicates an invalid email template for sending update email

Are you curious what happens if the user has been disabled by the admin? Well, it would NOT throw an exception and the reset password email will be sent! Firebase only throws an error when the user tries to reset a password at the reset password webpage. In my opinion, this is not perfect and would be better for the SDK to throw an exception in this case.

The overall flow of reset password at the webpage: