在密码重置表上,用户提供current_password,密码和密码确认.有没有办法在验证规则中指定current_password(它的哈希值)必须与数据库值匹配?
原文链接:https://www.f2er.com/laravel/136826.html目前我有这个:
$rules = array( 'current_password' => 'required','password' => 'required|confirmed|min:22' );
谢谢.
UPDATE
感谢@ChrisForrence和@Ben,我想出了以下内容,效果很好!非常感激.希望这会帮助别人:
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 );