auth = $auth; $this->passwords = $passwords; $this->middleware('guest'); } /** * Get the e-mail subject line to be used for the reset link email. * * @return string */ protected function getEmailSubject() { return isset($this->subject) ? $this->subject : 'Your Password Reset Link'; } /** * Display the password reminder view. * * @return Response */ public function getRemind() { return \View::make('Public.LoginAndRegister.ForgotPassword'); } /** * Handle a POST request to remind a user of their password. * * @return Response */ public function postRemind(Request $request) { $this->validate($request, ['email' => 'required']); $response = $this->passwords->sendResetLink($request->only('email'), function ($m) { $m->subject($this->getEmailSubject()); }); switch ($response) { case PasswordBroker::RESET_LINK_SENT: return redirect()->back()->with('status', trans($response)); case PasswordBroker::INVALID_USER: return redirect()->back()->withErrors(['email' => 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)) { \App::abort(404); } return \View::make('Public.LoginAndRegister.ResetPassword')->with('token', $token); } /** * Handle a POST request to reset a user's password. * * @return Response */ public function postReset(Request $request) { $this->validate($request, [ 'token' => 'required', 'email' => 'required', 'password' => 'required|confirmed', ]); $credentials = $request->only( 'email', 'password', 'password_confirmation', 'token' ); $response = $this->passwords->reset($credentials, function ($user, $password) { $user->password = bcrypt($password); $user->save(); $this->auth->login($user); }); switch ($response) { case PasswordBroker::PASSWORD_RESET: \Session::flash('message', 'Password Successfully Reset'); return redirect(route('login')); default: return redirect()->back() ->withInput($request->only('email')) ->withErrors(['email' => trans($response)]); } } }