简体   繁体   中英

Laravel Change Password Reset URL

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM