//Route as follows:
Route::get('forgotPassword', array('as' => 'forgotPassword', 'uses' => 'RemindersController@getRemind'));
Route::post('postRemind', array('as' => 'postReminder', 'uses' => 'RemindersController@postRemind'));
Route::get('reset/{token}', array('as' => 'getReset', 'uses' => 'RemindersController@getReset'));
Route::post('reset', 'RemindersController@postReset');
//reminder.blade.php
{{ URL::route('getReset', Session::get('_token')) }}
//remindersController
public function getReset($token = null)
{
if (is_null($token)) App::abort(404);
return View::make('frontend.users.password.reset')->with('token', $token);
}
It did send me the email and the url is like this:
http://localhost/html5lav/public/user/reset/2LEYtzhB0QXfHJH3eC4hj2UH6VLXJsc3iawk6iAv
Howerver, i cannot open it . it shows:
Symfony \\ Component \\ HttpKernel \\ Exception \\ NotFoundHttpException
i wonder why did this happen? Thanks
The following problem is solved . but now the problem is that And once submiting the final reset page ,it show :laravel the password reset token is invalid. the url is like: localhost/html5lav/public/user/reset/, Thanks
Your route responds to POST requests because it is Route::post and not Route::get(). Other problem might be that you are sending to request to a route user/reset/{token} and you might not have such route (though I am not sure, because I don't see the whole routes.php file, maybe the reset/{token} is prefixed).
Change these two line:
Route::post('reset/{token}', array(
'as' => 'getReset',
'uses' => 'RemindersController@getReset'
));
Route::post('reset/{token}', 'RemindersController@postReset');
To:
Route::get('reset/{token}', array(
'as' => 'getReset',
'uses' => 'RemindersController@getReset'
));
Route::post('reset', 'RemindersController@postReset');
<?php
class RemindersController extends Controller {
/**
* Display the password reminder view.
*
* @return Response
*/
public function getRemind()
{
return View::make('frontend.users.password.remind');
}
/**
* Handle a POST request to remind a user of their password.
*
* @return Response
*/
public function postRemind()
{
Password::remind(Input::only('email'), function($message)
{
$message->subject('HTML5COL学院密码重置邮件');
});
switch ($response = Password::remind(Input::only('email')))
{
case Password::INVALID_USER:
return Redirect::back()->with('error', Lang::get($response));
case Password::REMINDER_SENT:
return Redirect::back()->with('status', Lang::get($response));
//假如忘记密码通知信成功的寄发给用户,则会有一个 status 信息被暂存在 session 内;假如寄发失败的话,则取而代之的会有一个 error 信息被暂存。
}
}
/**
* Display the password reset view for the given token.
*
* @param string $token
* @return Response
*/
public function getReset($token = null)
{
if (is_null($token)) App::abort(404);
return View::make('frontend.users.password.reset')->with('token', $token);
}
/**
* Handle a POST request to reset a user's password.
*
* @return Response
*/
public function postReset()
{
$credentials = Input::only(
'password', 'password_confirmation', 'token'
);
$response = Password::reset($credentials, function($user, $password)
{
$user->password = Hash::make($password);
$user->save();
});
switch ($response)
{
case Password::INVALID_PASSWORD:
case Password::INVALID_TOKEN:
case Password::INVALID_USER:
return Redirect::back()->with('error', Lang::get($response));
case Password::PASSWORD_RESET:
return Redirect::to('/');
}
}
}
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.