Simon Suh
Simon Suh

Reputation: 10882

How do I log in a user in Laravel?

I'm practicing manual authentication in Laravel for learning purposes, following along laracasts.com and reading the manual user authentication related documentation here - https://laravel.com/docs/5.4/authentication#authenticating-users

My login controller code is as follows:

public function loginSubmit() {
  $email = request('email');
  $password = request('password');

  if (Auth::attempt(['email' => $email, 'password' => $password])) {
    return 'logged in';
  } else {
    return 'not logged in';
  }

Albeit the password not being hashed, I am using the Auth::attempt with the correct email and password information but am not able to return 'logged in'. How can I get the login to work with Auth::attempt ?

Upvotes: 0

Views: 190

Answers (2)

Andrew
Andrew

Reputation: 7

You can use a helper: hash('md5',$request->password)

Upvotes: 0

Diego Poveda
Diego Poveda

Reputation: 120

You need to hash the password

use Illuminate\Support\Facades\Hash;

$password = Hash::make($request->password);

Upvotes: 3

Related Questions