Search code examples
laravellaravel-5.4reset-password

Password reset form is not showing by clicking reset Password laravel 5.4 authentication


I'm trying to send the link through mailtrap.io when someone forgot the password, so when I try to send the link for resetting the password, the link is successfully sent but after clicking the reset password or the link that is provided there , it shows me again the view that I used for sending the link. here is the link I'v created. I want to show the form that says : enter New Password

Confirm New Password

Click here to reset your password !!! <br>
<a href="{{ $link = url('password/request',$token).'?email='.urlencode($user->getEmailForPasswordReset()) }}">{{ $link }}
</a>

** Route Files **

 Route::get('password/reset/{token?}', 'Auth\ForgotPasswordController@showLinkRequestForm')->name('password.request');
 Route::post('password/email', 'Auth\ForgotPasswordController@sendResetLinkEmail')->name('password.email');
 Route::get('password/reset/{token}', 'Auth\ResetPasswordController@showResetForm')->name('password.reset');
 Route::post('password/reset', 'Auth\ResetPasswordController@reset');

Solution

  • Two of your routes are clashing, if the token is provided the second route will never be hit, to fix this you have to remove {token?} from the first one:

    Change:

    Route::get('password/reset/{token?}', 'Auth\ForgotPasswordController@showLinkRequestForm')->name('password.request');
    Route::get('password/reset/{token}', 'Auth\ResetPasswordController@showResetForm')->name('password.reset');
    

    To this:

    Route::get('password/reset', 'Auth\ForgotPasswordController@showLinkRequestForm')->name('password.request');
    Route::get('password/reset/{token}', 'Auth\ResetPasswordController@showResetForm')->name('password.reset');