How to Reset Password in Laravel using Gmail

How to Reset Password in Laravel using Gmail

ยท

3 min read

It's very common that we forgot our password happens everytime but how do we fix that, well stay here and I'll show you how you can reset your password with Laravel Breeze.

Table of contents

  1. Create new Laravel project
  2. Configure Database credentials
  3. Install Laravel Breeze
  4. Configure Gmail
  5. Configure Gmail credentials in Laravel
  6. Reset Password

1. Create new Laravel project.

Run this command

composer create-project  laravel/laravel reset-password-project

2. Configure Database Credentials

Open .env file and set your credentials

database_credentials.png

3. Install Laravel Breeze

To install Laravel Breeze execute this command in your terminal

composer require laravel/breeze

After installing the package, run this command

php artisan breeze:install

To finish this part you need to run

npm install && npm run dev

Note: You need to have installed node.js to execute npm install && npm run dev

Finally we need to run our migrations.

php artisan migrate

Now we can see the registration and login page. Let's go to the registration page and create a new user like the image below.

register_new_user.png

Let's move to the next step.

4. Configure Gmail.

To reset the password we will be using the reset link via email, of course, we need to configure an email provider in this case I'm going to use Gmail.

Let's go to the user icon located on the right-hand side navbar, click there, you should see a menu and click in manage your account

manage_your_account.png

After that, you should see a new screen, in the left-hand side menu click on security like the image below.

security.png

Then select 2-Step Verification and you'll see this screen

2-step.png

Click on GET STARTED and you need to login again to confirm your identity then you have to select between a text message or voice call to complete this, when you insert the right code you'll receive a message to confirm the 2-Step Verification was turn on.

Almost done here. Let's go to security menu (again) and click on App passwords (This would again ask you to login and then authenticate using OTP), after that, you select mail and Other (Custom name) in this screen

select_mail.png

Then you can create a new password on this screen. Put the name you want and click GENERATE

generate.png

Cool!!! Everything is ready.

5. Configure Gmail credentials in Laravel

In the .env configure your Gmail credentials like this

MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=465
MAIL_USERNAME=youraccount@gmail.com
MAIL_PASSWORD=yourapppassword
MAIL_ENCRYPTION=ssl

6. Reset Password

Let's to the login page.

login.png

Then click on Forgot your password? and you should see this screen

reset_send_email.png

Put the email you want to change the password, click EMAIL PASSWORD RESET LINK if everything is good you'll see this message

reset_password.png

Just verify in your email account if the message was sent, if you can see the email you can access this screen

final_reset.png

This is how you can reset your password!!!!.

Happy coding โ˜•. Thanks for reading ๐Ÿ™.

ย