Laravel 5 - validator for current user password
Asked Answered
A

1

7

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?

Advertence answered 17/4, 2015 at 8:43 Comment(0)
I
13

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

return Hash::check( $value, $user->password );
Iou answered 17/4, 2015 at 8:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.