Limon Monte
Limon Monte

Reputation: 54379

Laravel 5 - validator for current user password

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

Answers (1)

Joe
Joe

Reputation: 15802

You should use Hash::check( $plaintext, $hashed ) instead:

return Hash::check( $value, $user->password );

Upvotes: 13

Related Questions