token = $token; $this->email = request()->string('email'); } /** * Reset the password for the given user. */ public function resetPassword(): void { $this->validate([ 'token' => ['required'], 'email' => ['required', 'string', 'email'], 'password' => ['required', 'string', 'confirmed', Rules\Password::defaults()], ]); // 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( $this->only('email', 'password', 'password_confirmation', 'token'), function ($user) { $user->forceFill([ 'password' => Hash::make($this->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. if ($status != Password::PASSWORD_RESET) { $this->addError('email', __($status)); return; } Session::flash('status', __($status)); $this->redirectRoute('login', navigate: true); } }; ?>