validate($request, $this->rules(), $this->validationErrorMessages()); // Here we will attempt to reset the user's password. If it is successful we // will update the password on an actual user model and persist it to the // database. Otherwise we will parse the error and return the response. $response = $this->broker()->reset( $this->credentials($request), function ($user, $password) { $this->resetPassword($user, $password); } ); // If the password was successfully reset, we will redirect the user back to // the application's home authenticated view. If there is an error we can // redirect them back to where they came from with their error message. return $response == Password::PASSWORD_RESET ? $this->sendResetResponse($request, $response) : $this->sendResetFailedResponse($request, $response); } /** * Get the response for a successful password reset. * * @param \Illuminate\Http\Request * @param string $response * @return \Illuminate\Http\RedirectResponse */ protected function sendResetResponse(Request $request,$response) { if ($request->expectsJson()) { return response()->json([ 'status' => trans($response) ]); } return redirect($this->redirectPath()) ->with('status', trans($response)); } /** * Get the response for a failed password reset. * * @param \Illuminate\Http\Request * @param string $response * @return mixed */ protected function sendResetFailedResponse(Request $request, $response) { if ($request->expectsJson()) { return new JsonResponse(['email' => trans($response) ], 422); } return redirect()->back() ->withInput($request->only('email')) ->withErrors(['email' => trans($response)]); } /** * Display the password reset view for the given token. * * If no token is present, display the link request form. * * @param \Illuminate\Http\Request $request * @param string|null $token * @return \Illuminate\Http\Response */ public function showResetForm(Request $request, $token = null) { return view('adminlte::auth.passwords.reset')->with( ['token' => $token, 'email' => $request->email] ); } /** * Create a new controller instance. * * @return void */ public function __construct() { $this->middleware('guest'); } }