H
H
honormgr2016-12-31 19:34:33
Laravel
honormgr, 2016-12-31 19:34:33

Hashing not working correctly?

Hello.
I've been fighting for an hour already, the Hash class does not work
Code:

public function authenticate(Request $request)
    {

    $name = $request->input('name');
    $password = Hash::make($request->input('password'));
    $user = User::where('name', $name)->first();

    if (Hash::check($password, $user->password))
        {
            return 'nice';
        }
        else
        {
            return 'Ошибка! Введенный пароль не совпадает с текущим!';
        }
    }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Victor, 2016-12-31
@honormgr

You are comparing two hashes, but you need to pass a clean password entered by the user and a hash from the database in check:

if (Hash::check('password', $user->password)) {
    // пароль верный
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question