Laravel Resetting Passwords


Laravel Resetting Passwords – The Laravel Resetting Passwords provide a way to user to reset their password.


Laravel Resetting Passwords.

Let us understand how to use laravel Resetting Passwords.

Function:-

There are some followings function available in laravel Resetting Passwords.

  • 1. Introduction.
  • 2. Database Considerations.
  • 3. Routing.
  • 4. Views.
  • 5. After Resetting Passwords.
  • 6. Customization.

1. Introduction.

Mostly web application provide a way for users to rest their passord, if they forgotten password. Even forcing you to re-implement this on each application. Its provides a method for sending password reminders and performing password resets.

2. Database Considerations.

First verify that your App/User model implements the Illuminate/Contracts/Auth/CanResetPassword contract. The App/User model already included with the framework and use the Illuminate/Auth/Passwords/CanResetPassword trait to include the methods.

Generating The Reset Token Table Migration

Table must be created to store the password reset tokens. The migration for this table is included with Laravel and resides in the database/migrations directory.

php artisan migrate

3. Routing.

All the routes needed to perform passwords resets can be generated using the make:auth Artisan command.

php artisan make:auth

4. Views.

Laravel will generate all of the necessary view for password reset when the make:auth command is executed. Views are placed in resources/views/auth/passwords. You are free to customize them as need for your application.

5. After Resetting Passwords.

You have defined the routes and views to reset your users password, you can simply access the route in your browser at /password/reset.

After a password is reset, the user will automatically be logged into the application and redirected to /home.

protected $redirectTo = '/dashboard';

6. Customization.

Authentication Guard Customization

In your auth.php configuration file, you can configure multiple Guards, which can be used to define auth behaviour for multiple user tables. You can customize the included ResetPasswordController to use the guard of your choice by overriding the Gaurd
method on the controller.

Let’s look at a simple example.

use Illuminate\Support\Facades\Auth;

protected function guard()
{
    return Auth::guard('guard-name');
}

Password Broker Customization

In your auth.php configuration file, you can configure multiple password brokers which can be used to reset password on multiple user tables.

Let’s look at a simple example.

use Illuminate\Support\Facades\Password;

protected function broker()
{
    return Password::broker('name');
}

Reset Email Customization

You can easily modify the notification class used to send the password reset link to the user.First override the SendPasswordResetNotification on your user model. Then you can send the notification using any notification class you choose. The password reset $token is the first argument recieved by the method.

Let’s look at a simple example.

public function sendPasswordResetNotification($token)
{
    $this->notify(new ResetPasswordNotification($token));
}

Advertisements

Add Comment

📖 Read More