code-8
code-8

Reputation: 58662

How can I authenticate my user to log-in in Laravel?

I'm stuck trying to authenticate my user to log-in in Laravel 5.


I have

  $user = User::where('code','=', Input::get('code'))->first();
  $password = Input::get('password');
  $user->password = Hash::make($password);
  $user->code   =  $code;
  $user->username = Input::get('username');
  $user->active = 1;
  $user->save();

$auth = Auth::attempt(['username' => $user->username, 'password' => $user->password, 'active' => 1]);

when I do dd($auth);, It print out false.


It wired because I check my database, that user is there with :

What did I do wrong here ? Is it sth that they change in Laravel 5 ?

Upvotes: 1

Views: 107

Answers (1)

user1669496
user1669496

Reputation: 33068

You don't hash the password before you send it to the attempt() function. It will hash it again and compare it against the single hashed version.

Try this...

$auth = Auth::attempt(['username' => $user->username, 'password' => Input::get('password'), 'active' => 1]);

Upvotes: 2

Related Questions