[英]Laravel Auth::attempt() Fails after password change
我的Laravel身份验证完美运行。 我包括了密码更改功能。 更改密码后,该登录名对除第一个用户(uid =“ 1”)以外的所有用户均有效。 仅默认密码哈希对此用户有效。 对于其他密码哈希,登录尝试将失败。 我的代码如下:
用户控制器登录
public function postSignin() {
if (Auth::attempt(array('email'=>Input::get('email'), 'password'=>Input::get('password')))) {
return Redirect::to('users/dashboard')->with(array('message' => 'You are now logged in!', 'email' => Input::get('email')));
} else {
return Redirect::to('users/login')
->with('message', 'Your username/password combination was incorrect')
->withInput();
}
}
表架构
Schema::create('users', function($table)
{
$table->increments('id');
$table->string('firstname', 20);
$table->string('lastname', 20);
$table->string('email', 100)->unique();
$table->string('password', 255);
$table->string('remember_token', 255);
$table->timestamps();
});
密码更改控制器功能
public function postUpass() {
$user = User::find(Input::get('uid'));
if((Input::get('password'))==(Input::get('passconf'))){
$user->password = Hash::make(trim(Input::get('password')));
$user->save();
echo "Done";
//echo Hash::make(trim(Input::get('password')));
}
else {
echo "Check Passwords Again";
}
有人请帮我。
我目前无法发表评论,因此我必须通过发布答案来征求您的看法。 尽管我也想建议在postUpass函数中更改您访问用户的方式,因为最终用户可以很容易地更改它以更新另一个用户的密码。
//change this
$user = User::find(Input::get('uid'));
//to this
$user = Auth::user();
//since the user needs to be logged in
//to change their password anyway
另外,您是说一旦发布到postUpass函数,就始终会收到“再次检查密码”通知?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.