# Forgot Password

If an existing user forgot his password he has the possibility of resetting his password.

In the case of an user forgetting the credentials there is the possibility of resetting them. For resetting the password the user should use the Forgot password? button from the login page. The user must provide the email for the account and after that a link will be sent for resetting the password to the provided mail address.

The `App/Http/Controllers/SessionsController.php` handles the recovery of the password.

                    public function update(){

                        request()->validate([
                            'token' => 'required',
                            'email' => 'required|email',
                            'password' => 'required|min:8|confirmed',
                        ]);

                        $status = Password::reset(
                            request()->only('email', 'password', 'password_confirmation', 'token'),
                            function ($user, $password) {
                                $user->forceFill([
                                    'password' => ($password)
                                ])->setRememberToken(Str::random(60));

                                $user->save();

                                event(new PasswordReset($user));
                            }
                        );

                        return $status === Password::PASSWORD_RESET
                                    ? redirect()->route('login')->with('status', __($status))
                                    : back()->withErrors(['email' => [__($status)]]);
                    }