您好,我的密码提醒系统遇到一些奇怪的问题。此函数的返回始终是密码 token 不匹配。
这是记住 Controller
<?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.');
}
}
}
和Routes.php
Route::get('reset', function() {
return View::make('resetacc');
});
Route::get('password/reset/{token}', array(
'uses' => 'RemindersController@getReset',
'as' => 'resetpass'
));
存储在数据库中的 token 与提供给用户的 token 相同。
我有 laravel 版本 4.1 然后更新到 4.2.5
是因为更新过程吗?
谢谢
最佳答案
为了完整起见:此错误也可能意味着 token 已过期。
您可以在config/auth.php
中设置reminder.expire
。
默认为 60 分钟。
https://laravel.com/docs/5.1/authentication#after-resetting-passwords
关于php - Laravel 密码提醒 token 总是不匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24400323/