Laravel 5.4 comes with a built-in authentication library that works well for most cases. However, the documentation can be a little limited in some instances. One of those instances in the forgot password functionality. When a user requests to reset their password they enter their email address and hit submit. After which an email is sent to them with a token to reset their password. The problem is that once they click submit to have that email sent to them, Laravel by default, redirects back to that page. In some applications, you may not want this to be the default behavior. In my case, I wanted the user to be redirected back to the login screen with a status message that a reset link had been sent to them. Unfortunately, the Laravel 5.4 documentation does not give a clear explanation of how to achieve this. Googling and searching around the internet returns plenty of links for redirecting after the user resets their password, but not after the reset email has been sent to them.
Come to find out there is a simple fix to this issue. You simply need to override the default sendPasswordLinkResponse function from Illuminate/Foundation/Auth/SendsPasswordResetEmails.php in your App/Auth/ForgotPasswordController.php.
To begin, edit your App/Auth/ForgotPasswordController.php and add the following:
* Get the response for a successful password reset link.
* @param string $response
* @return \Illuminate\Http\RedirectResponse
public function sendResetLinkResponse($response)
return redirect()->route('login')->with('status', trans($response));
You can add whichever route you want to redirect to, in this case it goes back to the login page. Simple as that.
Latest posts by Jeff Mould (see all)
- Laravel 5.4 Redirect after Password Reset Email Sent - September 8, 2017
- How to Fix Laravel 5.2 Token Mismatch Errors - June 30, 2016
- How to Get Sirius XM Deals - May 27, 2016