$request]); } /** * Handle an incoming new password request. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\RedirectResponse * * @throws \Illuminate\Validation\ValidationException */ public function store(Request $request) { $request->validate( [ 'token' => ['required'], 'email' => ['required', 'email'], 'password' => ['required', 'min:8', 'max:255', 'confirmed'], ], [ 'email.email' => 'O "E-mail" deve ser um e-mail válido.', 'email.required' => 'O "E-mail" é um campo obrigatório.', 'password.required' => 'A "Nova Senha" é obrigatória!', 'password.min' => 'A "Nova Senha" deve contér no minímo 8 caracteres!', 'password.max' => 'A campo "Nova Senha" deve contér no máximo 255 caracteres!', 'password.confirmed' => 'As senhas devem ser iguais!', ] ); // 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. $status = Password::reset( $request->only('email', 'password', 'password_confirmation', 'token'), function ($user) use ($request) { $user->forceFill([ 'password' => Hash::make($request->password), 'remember_token' => Str::random(60), ])->save(); event(new PasswordReset($user)); } ); // 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 $status == Password::PASSWORD_RESET ? redirect()->route('login')->with('success', 'Sua senha foi alterada com sucesso!') : back()->withInput($request->only('email')) ->withErrors(['email' => __($status)]); } }