Laravel 8 Angular JWT Password Reset with Mailtrap Example

In this tutorial you will learn about the Laravel 8 Angular JWT Password Reset with Mailtrap Example and its application with practical example.

In this Laravel 8 Angular JWT Password Reset with Mailtrap Example Tutorial, I will show you how to create reset password feature in the Laravel 8 angular application with JWT auth and mailtrap. In this tutorial you will learn to create a password reset functionality in laravel and Angular using REST API with JWT Authentication and Mailtrap.

In this example we will create laravel APIs for reset password request and to reset the password. We will capture password reset request with the token. We will be using mailtrap to send password reset mail.

Laravel 8 Angular JWT Password Reset with Mailtrap Example

In this step by step tutorial I will demonstrate you how to create a password reset functionality with mailtrap in Angular using Laravel 8 REST API with JWT Authentication

  1. Clone Laravel Token-Based Authentication Repo
  2. Configure Mailtrap
  3. Reset Password Request
  4. Reset Password

Clone Laravel Token-Based Authentication Repo

In this step we will clone the repo using the following command:

Configure Mailtrap

Then, open .env and add the mailtrap details.

Password Reset Request

In this step we will create a controller PasswordResetRequestController using following command:

Open PasswordResetRequestController.php and place the following code.

Next we will create a mailable class for mail template and sending the mail.

Open App/Mail/SendMail.php and put the following code:

Consume Password Reset Request API

Next go to frontend/app/shared/auth.service.ts and put the following code in it:

Create Reset Password Form

Now, we will create a password reset form

Inside the frontend folder, add the following code in change-password-request.component.ts file.


Place the following code in change-password-request.component.html file.

Create Password Reset Mail Template

Now, go to views/Email/resetPassword.blade.php and put the following code in it to create the mailer template.

Laravel Password Reset Example

Set the authorize to true and define email and password fields inside the backend folder’s
app/Http/Requests/UpdatePasswordRequest.php.


Next, we have to create change password controller inside the backend folder. Use the following command to generate ChangePasswordController controller:


Now. Open ChangePasswordController.php and put the following code:


Now go to resources/routes/api.php and put the following code.

Register Password Update API in Service

Now, go to  frontend/app/shared/auth.service.ts and put the following code in it:

Create Password Update Form

Inside the frontend folder, open change-password.component.ts file and put the following code in it.


Inside the frontend folder, open change-password.component.html file and put the following code in it.

Define Angular Routes

Now, lets define some angular routes inside the app-routing.module.ts file.

Run Application

Start Laravel App
Now switch to the laravel project directory and run the app using following command:


Run Angular App

Now switch to angular project directory and run the angular project.

In this tutorial we have learn about the Laravel 8 Angular JWT Password Reset with Mailtrap Example and its application with practical example. I hope you will like this tutorial.