Laravel - Checking passwords before manually logging in

Viewed 5887

I'm getting problem with manually logging in users using Auth::loginUsingId . Before I do that I need to check if password matches and there is my problem. Password comparision is always returning false;

That's how I save password to DB:

    $user = User::create([
        'password' => Hash::make(Input::get('password')),
    ]);

And that's how I try to compare these two passwords

$u = User::where('username', $username)->first();    
$password = Hash::make(Input::get('password'));
var_dump($u->password == $password);

And this is returning false, and I don't know where the problem is.

EDIT: In DB field varchar is 70 char long, hash is 60 characters long

Ok I've noticed: that every time Hash::make gives another string from my password. How it's even possible? I mean how then Auth::attempt works?

1 Answers
Related