你好,我的密码提醒系统出现了一些奇怪的问题。此函数的返回值始终是密码令牌不匹配。
这里是记住控制器
<?php
class RemindersController extends Controller {
/**
* Display the password reminder view.
*
* @return Response
*/
public function getRemind()
{
return View::make('resetacc');
}
/**
* Handle a POST request to remind a user of their password.
*
* @return Response
*/
public function postRemind()
{
switch ($response = Password::remind(Input::only('email')))
{
case Password::INVALID_USER:
return Redirect::back()->with('message', Lang::get($response));
case Password::REMINDER_SENT:
return Redirect::back()->with('message', Lang::get($response));
}
}
/**
* 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('resetpass')->with('token', $token);
}
/**
* Handle a POST request to reset a user's password.
*
* @return Response
*/
public function postReset()
{
$credentials = Input::only(
'email', '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:
return Redirect::to('/reset')->with('message', Lang::get($response));
case Password::INVALID_USER:
return Redirect::back()->with('message', Lang::get($response));
case Password::PASSWORD_RESET:
return Redirect::to('/auth')->with('message', 'Password Reset anda berhasil, silahkan login.');
}
}
}
Route::get('reset', function() {
return View::make('resetacc');
});
Route::get('password/reset/{token}', array(
'uses' => 'RemindersController@getReset',
'as' => 'resetpass'
));
存储在数据库中的令牌与给定给user的令牌相同。
我有laravel版本4.1,然后更新到4.2.5
是因为更新过程吗?
谢谢
为了完整起见:这个错误也可能意味着令牌已经过期。
可以在"config/auth.php
"中设置reminder.expire
。
默认为60分钟。
https://laravel.com/docs/5.1/authentication after-resetting-passwords
你需要添加一些像{{ Form::hidden('token', $token) }}
到你的重置形式
如果应用程序中有子域路由,则必须修改getReset方法,以便在函数的参数列表中包含子域参数。
public function getReset($club="",$token = null)
{
if (is_null($token)) {
throw new NotFoundHttpException;
}
return view('auth.reset')->with('token', $token);
}