3 namespace BookStack\Http\Controllers\Auth;
5 use BookStack\Http\Controllers\Controller;
6 use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
7 use Illuminate\Http\Request;
10 class ForgotPasswordController extends Controller
13 |--------------------------------------------------------------------------
14 | Password Reset Controller
15 |--------------------------------------------------------------------------
17 | This controller is responsible for handling password reset emails and
18 | includes a trait which assists in sending these notifications from
19 | your application to your users. Feel free to explore this trait.
23 use SendsPasswordResetEmails;
26 * Create a new controller instance.
30 public function __construct()
32 $this->middleware('guest');
33 parent::__construct();
38 * Send a reset link to the given user.
40 * @param \Illuminate\Http\Request $request
41 * @return \Illuminate\Http\RedirectResponse
43 public function sendResetLinkEmail(Request $request)
45 $this->validate($request, ['email' => 'required|email']);
47 // We will send the password reset link to this user. Once we have attempted
48 // to send the link, we will examine the response then see the message we
49 // need to show to the user. Finally, we'll send out a proper response.
50 $response = $this->broker()->sendResetLink(
51 $request->only('email')
54 if ($response === Password::RESET_LINK_SENT) {
55 $message = 'A password reset link has been sent to ' . $request->get('email') . '.';
56 session()->flash('success', $message);
57 return back()->with('status', trans($response));
60 // If an error was returned by the password broker, we will get this message
61 // translated so we can notify a user of the problem. We'll redirect back
62 // to where the users came from so they can attempt this process again.
63 return back()->withErrors(
64 ['email' => trans($response)]