In this episode, we're adding the "Forgot Password" feature to our login flow. We'll start by updating the sign-in modal to include a link for recovering accounts. When users click on this link, they'll be taken to a new modal where they can enter their email address to request a recovery email.
We'll make sure this feature is only available if password resets are enabled in our config. Next, we'll spin up a controller to handle displaying the recovery modal and set up the necessary routes and middleware so only guests (not logged-in users) can access them. Then, it's just a matter of building out the modal itself—pretty similar to our confirm password modal, but with a field for the user's email address.
After wiring up the front end, we'll make sure submitting the form actually triggers an email by hooking it up to the built-in password reset email route. There's a bit of troubleshooting as we realize the reset email requires a route for handling password resets, so we'll scaffold a basic controller and route for that too.
Finally, we'll add some nice finishing touches: when the recovery email is sent, the user sees a toast notification so they know what happened. At the end of the video, we test the entire flow, so a user can request a password reset email, receive it, and click through to the next step — which we'll build in the following episode!