0

OVERVIEW:

I'm creating a password reset functionality using the built in system in Laravel 5.1, I have followed the instructions exactly how it says here.

The view in resources/views/emails/password.blade.php receives a variable $token which contains the password reset token to match the user to the password reset request. Within the view, I have the following code which is supposed to create a URL link of the page where the user set the new password:

   Click here to reset your password: {{ url('password/reset/'.$token) }}

PROBLEM:

It does not send the email at all. But I have realized that, if I remove the last trailing slash (see below):

   Click here to reset your password: {{ url('password/reset'.$token) }}

I receive something like http://mywebsite.com/password/reset35df435dfgdfg...

CONCLUSION:

Whenever there is a trailing slash between password/reset/ and the $token, the email is not sent. Even when I manually type the URL.

Why would the / before the $token affect on the email being sent? Any ideas?

ATTEMPTED SOLUTIONS:

 url('password/reset', [$token]); //DID NOT WORK

 action('Auth\PasswordController@getEmail', ['token' => $token]);  //DID NOT WORK

 route('password/email', ['token' => $token]); //DID NOT WORK

 url('password/reset/'.$token); //DID NOT WORK

2 Answers 2

0

Try like this

url helper function second parameter is parameter array to pass with the url. Instead of append parameters to end of the url.., you can use like bellow.

url('password/reset', [$token]);
Sign up to request clarification or add additional context in comments.

2 Comments

I'm using php mail, I found a solution, the issue is unusual, but my approach worked! Vote up for you! :) thanks for the help! @Alupotha
Is the source of this issue down to what routes are defined for the application? If password/{whatever} is defined but not password/reset/{token} then the could laravel be trying and failing to map to known routes?
0

I found a solution! This is not usual, but if you add a backward trailing slash, it will keep the forward slash and it won't have a problem with the token.

url('password/reset\/', [$token]);

Thanks & Good luck!

1 Comment

Not convinced about this. It is certainly true that a constant string cannot end in a backward slash, as it escapes the closing quote. That would then result in a parsing error. But a forward slash? That should not have any issue at all.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.