Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.3] Customizable response for password reset link #16982

Merged
merged 2 commits into from
Dec 27, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 27 additions & 6 deletions src/Illuminate/Foundation/Auth/SendsPasswordResetEmails.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,34 @@ public function sendResetLinkEmail(Request $request)
$request->only('email')
);

if ($response === Password::RESET_LINK_SENT) {
return back()->with('status', trans($response));
}
// If the password reset link was successfully send, we will redirect
// the user back to the application's password forgot view. If there is an error
// we can redirect them back to where they came from with their error message.
return $response == Password::RESET_LINK_SENT
? $this->sendResetLinkResponse($response)
: $this->sendResetLinkFailedResponse($request, $response);
}

// If an error was returned by the password broker, we will get this message
// translated so we can notify a user of the problem. We'll redirect back
// to where the users came from so they can attempt this process again.
/**
* Get the response for a successful password reset link.
*
* @param string $response
* @return \Illuminate\Http\Response
*/
protected function sendResetLinkResponse($response)
{
return back()->with('status', trans($response));
}

/**
* Get the response for a failed password reset link.
*
* @param \Illuminate\Http\Request
* @param string $response
* @return \Illuminate\Http\RedirectResponse
*/
protected function sendResetLinkFailedResponse(Request $request, $response)
{
return back()->withErrors(
['email' => trans($response)]
);
Expand Down