在密码重置表单上,用户提供current_password、password和password-confirmation。是否有一种方法在验证规则中指定current_password (它的散列值)必须与数据库值匹配?
目前,我有以下几点:
$rules = array(
'current_password' => 'required',
'password' => 'required|confirmed|min:22'
); 谢谢。
更新
多亏了“佳士得·福伦斯”和“本”,我想出了以下几个非常有效的方法!非常感谢。希望这能帮助到其他人:
Validator::extend('hashmatch', function($attribute, $value, $parameters)
{
return Hash::check($value, Auth::user()->$parameters[0]);
});
$messages = array(
'hashmatch' => 'Your current password must match your account password.'
);
$rules = array(
'current_password' => 'required|hashmatch:password',
'password' => 'required|confirmed|min:4|different:current_password'
);
$validation = Validator::make( Input::all(), $rules, $messages );发布于 2014-07-18 17:21:20
您不能,bcrypt散列是唯一的(它们有自己的随机盐类),所以即使您知道用户的纯文本密码,您也无法进行散列到散列的比较。
实际上,您可以通过在控制器上执行bcrypt来检查纯文本密码和一个Hash::check('plain text password', 'bcrypt hash')哈希。
https://stackoverflow.com/questions/24830119
复制相似问题