1
votes

I'm currently on a project that uses the base Laravel authentication provided by running php artisan make:auth and I'm experiencing issues with trying to use the reset password functionality. The password reset email is sent out perfectly fine but the URL that's generated on the email when clicked returns a 404 (Also happens when copying the URL at the bottom of the email). Is there a way to modify the URL generated in the email to the "Working URL" as shown below? This has been proven to work by manually changing the "Current URL" to the "Working URL" in the browser once the link in the password reset emails has been clicked.

Current URL: [App Path]/[Email]/password/reset/[Token]
Working URL: [App Path]/[locale]/password/reset/[Token]?email=[Email]

The project does contain information for language switching which is why [locale] needs to be included in the URL but running the following on my route which works for all blade.php file extensions except for the password reset URL.

Route::group([
  'prefix' => '{locale}',
  'where' => ['locale' => '[a-zA-Z]{2}'],
  'middleware' => 'setlocale'], function() {
    Auth::routes();
});

Any advice or links to documentation that talks about this would be helpful as I've not been able to find anything myself.

1
are you looking for a way to manually change the URL?Uzair Riaz
when you say manually, do you mean in the code? because I need to know how to change the URL generated when the email is sent, should I look at making a middleware for this or is there a way I can pass the new parameter into the email template?Adam_R
Is there a php file I need to change or should it be the password reset email notification that needs to be adjustedAdam_R

1 Answers

1
votes

I managed to partially solve the issue with the password reset URL by creating a new route to catch the incorrect URL and redirect it with the correct path:

Route::get('{email}/password/reset/{token}', function($email, $token){
    return redirect('/en/password/reset/'.$token.'?email='.$email);
});

However, I'm still unable to use the locale in place of the /en/ and when I try to process the password reset it comes up with an error on entering the credentials stating: This password reset token is invalid. but this has been recently generated, any suggestions would be helpful, the research I have done all seem to use a custom password reset controller which doesn't help me in this situation.