gavin_c's avatar

Fortify forgot password link and reset password functionality.

Hi Folks, I'm having problems with the forgot password link on the login form as well as the reset password form not showing. I'm using fortify, so FortifyService Provider is being used for routing. here is the code I have so far:

FortifyServiceProvider.php:

also, I have my login and register blade views sitting with an admin folder under views. But my forgot-password and reset-password blade file are broken somehow. Are the routes pointing to right location? What get's sent when you click the password reset link? and with the email that has the reset password link, what code is within that? Do I need to add something to routes/web .php? Trying to figure out whats missing...

forgot-password.blade.php:

reset-password.blade.php:

If someone can give me a hand with fixing these, that would be great. cheers.

0 likes
1 reply
LaryAI's avatar
Level 58

To resolve the issues with the forgot password and reset password functionality using Laravel Fortify, let's go through a few steps to ensure everything is set up correctly.

1. Verify Fortify Configuration

Ensure that your FortifyServiceProvider is correctly configured to handle the views for password reset. It looks like you have already set up the views correctly, but let's double-check the method names and routes.

Fortify::requestPasswordResetLinkView(function () {
    return view('admin.forgot-password');
});

Fortify::resetPasswordView(function (Request $request) {
    return view('admin.reset-password', ['request' => $request]);
});

2. Check Routes

Fortify automatically registers the necessary routes for password reset. However, ensure that your RouteServiceProvider is loading the Fortify routes. You don't need to add anything to routes/web.php for Fortify's password reset functionality.

3. Verify Blade Templates

Ensure that your Blade templates are correctly set up. The forgot-password.blade.php and reset-password.blade.php should be in the resources/views/admin directory.

4. Correct Form Actions

In your Blade templates, ensure the form actions are pointing to the correct routes. Fortify uses specific route names for these actions:

  • For the forgot password form, use password.email:

    <form method="POST" action="{{ route('password.email') }}">
    
  • For the reset password form, use password.update:

    <form method="POST" action="{{ route('password.update') }}">
    

5. Check Email Configuration

Ensure your email configuration is set up correctly in .env to send the password reset emails. You should have something like:

MAIL_MAILER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=your_username
MAIL_PASSWORD=your_password
MAIL_ENCRYPTION=tls
[email protected]
MAIL_FROM_NAME="${APP_NAME}"

6. Verify Email Template

Fortify uses Laravel's built-in notifications to send the password reset email. Ensure that your App\Providers\AuthServiceProvider is not overriding the default behavior unless necessary.

7. Debugging

If the forms are still not working, check the following:

  • Ensure there are no JavaScript errors in the console.
  • Check the network tab in your browser's developer tools to see if the requests are being sent and if there are any errors.
  • Look at the Laravel logs in storage/logs/laravel.log for any errors related to the password reset process.

By following these steps, you should be able to resolve the issues with the forgot password and reset password functionality in your Laravel application using Fortify. If you encounter specific errors, feel free to provide more details for further assistance.

Please or to participate in this conversation.