passwords = $passwords; $this->middleware('guest'); } /** * Display the form to request a password reset link. * * @return Response */ public function getEmail() { return view('password.email'); } /** * Send a reset link to the given user. * * @param Request $request * @return Response */ public function postEmail(Request $request) { switch ($response = $this->passwords->sendResetLink($request->only('email'))) { case PasswordBroker::INVALID_USER: return redirect()->back()->withErrors(['email' =>trans($response)]); case PasswordBroker::RESET_LINK_SENT: return redirect()->back()->with('status', trans($response)); } } /** * Display the password reset view for the given token. * * @param string $token * @return Response */ public function getReset($token = null) { if (is_null($token)) { throw new NotFoundHttpException; } return view('password.reset')->with('token', $token); } /** * Reset the given user's password. * * @param Request $request * @return Response */ public function postReset(Request $request) { $credentials = $request->only( 'email', 'password', 'password_confirmation', 'token' ); $response = $this->passwords->reset($credentials, function($user, $password) { $user->password = bcrypt($password); $user->save(); }); switch ($response) { case PasswordBroker::INVALID_PASSWORD: case PasswordBroker::INVALID_TOKEN: case PasswordBroker::INVALID_USER: return redirect()->back()->withErrors(['email' => trans($response)]); case PasswordBroker::PASSWORD_RESET: return redirect()->to('/'); } } }