Reputation: 54379
I have password change form and there's two fields in it: old_password
and new_password
.
I'm stuck with validator for old password, here's what I done:
Validator::extend('old_password', function($attribute, $value) use ($user) {
return $user->password === Hash::make($value);
});
But Hash::make($value)
always generates different result with the same $value
.
How can I make validator to match current user password?
Upvotes: 7
Views: 3596
Reputation: 15802
You should use Hash::check( $plaintext, $hashed )
instead:
return Hash::check( $value, $user->password );
Upvotes: 13