Reset Password

An email is sent to the user's address to help him reset his password.


The user can access the reset password page by clicking the button found in the email. The link for resetting the password is available for 12 hours and is unique for the user. The user must add the email, the password and confirm the password for his password to be updated.

The App/Http/Controllers/ChangePasswordController.php helps the user reset the password.

Copy
                        
                public function changePassword(Request $request)
                {

                    $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' => Hash::make($password)
                            ])->setRememberToken(Str::random(60));

                            $user->save();

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

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