mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-05-25 08:09:59 +08:00
Improved password reset flow with notifications.
Also added links to sign-in/register. Fixed links in emails sent out. Fixes #210 and #218.
This commit is contained in:
@ -4,6 +4,8 @@ namespace BookStack\Http\Controllers\Auth;
|
||||
|
||||
use BookStack\Http\Controllers\Controller;
|
||||
use Illuminate\Foundation\Auth\ResetsPasswords;
|
||||
use Illuminate\Http\Request;
|
||||
use Password;
|
||||
|
||||
class PasswordController extends Controller
|
||||
{
|
||||
@ -29,4 +31,46 @@ class PasswordController extends Controller
|
||||
{
|
||||
$this->middleware('guest');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Send a reset link to the given user.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function sendResetLinkEmail(Request $request)
|
||||
{
|
||||
$this->validate($request, ['email' => 'required|email']);
|
||||
|
||||
$broker = $this->getBroker();
|
||||
|
||||
$response = Password::broker($broker)->sendResetLink(
|
||||
$request->only('email'), $this->resetEmailBuilder()
|
||||
);
|
||||
|
||||
switch ($response) {
|
||||
case Password::RESET_LINK_SENT:
|
||||
$message = 'A password reset link has been sent to ' . $request->get('email') . '.';
|
||||
session()->flash('success', $message);
|
||||
return $this->getSendResetLinkEmailSuccessResponse($response);
|
||||
|
||||
case Password::INVALID_USER:
|
||||
default:
|
||||
return $this->getSendResetLinkEmailFailureResponse($response);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the response for after a successful password reset.
|
||||
*
|
||||
* @param string $response
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
protected function getResetSuccessResponse($response)
|
||||
{
|
||||
$message = 'Your password has been successfully reset.';
|
||||
session()->flash('success', $message);
|
||||
return redirect($this->redirectPath())->with('status', trans($response));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user