I use Laravel 5.3. I want to use form validation to test the hash for user's password.
Here is my code :
$validator = Validator::make($request->all(), [
'old_password' => 'required|max:20|min:6',
'new_password' => 'required|max:20|min:6',
'new_password_confirm' => 'required|same:new_password',
]);
// test old password
if (! Hash::check($request->old_password, $user->user_passwd)) {
$validator->errors()->add('end', 'The end time must be within three hours of the start');
}
This is not working, even if the conditon is verified. I've tested this :
Validator::extend('old_password', function($attribute, $value) use ($user) {
return Hash::check($value, $user->user_passwd);
});
But I don't understand how to use this ?