VLS
VLS

Reputation: 445

Password reset laravel 4.2 with Token

I'm new to Laravel and I making some test on a system which use version 4.2. I'm trying to follow Documentation for password reset. So far I'm able to post my email for password reset and I get token on my email.

When I open the URL from email with the token I get this error:

exception 'Symfony\Component\HttpKernel\Exception\NotFoundHttpException'

The url is: http://example.com/reset/20e2535a11f7c88d1132c55c752a3a8569adbf5f

This is my route

Route::get('/password', ['uses' => 'RemindersController@getRemind']);
Route::get('/reset', ['uses' => 'RemindersController@getReset']);

This is in RemindersController

public function getReset($token = null)
{
    if (is_null($token)) App::abort(404);

    return View::make('site.reset')->with('token', $token);
}

And the form from the doc's

<form action="{{ action('RemindersController@postReset') }}" method="POST">
    <input type="hidden" name="token" value="{{ $token }}">
    <input type="email" name="email">
    <input type="password" name="password">
    <input type="password" name="password_confirmation">
    <input type="submit" value="Reset Password">
</form>

I understand the error.. it is saying that the path/file isn't found but it is there..

Upvotes: 2

Views: 933

Answers (2)

Blueblazer172
Blueblazer172

Reputation: 600

in your html form, there is the action() method called RemindersController@postReset:

<form action="{{ action('RemindersController@postReset') }}" method="POST">
    <input type="hidden" name="token" value="{{ $token }}">
    <input type="email" name="email">
    <input type="password" name="password">
    <input type="password" name="password_confirmation">
    <input type="submit" value="Reset Password">
</form>

but your route uses GET. You have to use POST

change your route from:

Route::get('/reset', ['uses' => 'RemindersController@getReset']);

to:

Route::post('/reset', ['uses' => 'RemindersController@getReset']);

i think you could use this way. its maybe better:

Route::match(['GET','POST'], ['uses' => 'RemindersController@getRemind']);



Update: Route should have also token in it because the url is /reset/token:

Route::get('/reset/{token}', ['uses' => 'RemindersController@getReset']);

Upvotes: 1

Tom St
Tom St

Reputation: 911

check if your default controller or default security controller isn't loaded somewhere and it doesn't not overwrite the 'reset' route, get in your application directory using command line and type:

php artisan routes

This should show you if your route is registered and to which controller/action.

Upvotes: 1

Related Questions