A scenario you will inevitably run into is users needing to reset their passwords for security reasons or they lost and forgot their password.
We'll learn how to send our users an email to reset their passwords, after we send the email, we'll display a notification alert with ionic alertController to the user and redirect them to the login page.
Instructor: [0:01] Now, we're going to handle what to do when the user resets their account. Firebase authentication has a function called sendPasswordResetEmail, and this function does all of the work for us. It takes the current authentication instance, and it takes the user's email.
[0:24] What it does is that once the user clicks Reset password adding their email, it's going to use Firebase to send an email for the user to reset their password. All of that is going to be handled by Firebase and not by our application.
[0:39] This returns an empty promise and here instead of navigating the user to the home page, we're going to redirect them back to login.
[0:49] Before we redirect them, we are going to do something different. We're going to display an alert and for that, I'm going to use Ionic's AlertController. Then here after Firebase sends the reset email, we are going to trigger an alert.
[1:12] This alert is going to have a message where we are going to tell the user that we just sent the email. This one is going to have one button. It's an OK button and when the user clicks it, now we are going to navigate them to the login page.
[1:41] If I save this and go to forgot password, I can add my email here, click Continue. When it sends the email, it's going to say, "We just sent the password reset link, please check your email." As soon as I click OK, it redirects me back to the login page.