mardi 23 août 2016

How to login without password using Auth::attempt in Laravel 5.0?

I am using Laravel 5.0. I want do a login only with username (no password) because I am using Single Sign On to access to my Laravel project, so if user success login in Single Sign On, it will check to my database if the username of the user who login has registered or not.
I have looking for this all day but I still have found the clue.

I have got an error:

Argument 1 passed to Illuminate\Auth\Guard::login() must implement interface Illuminate\Contracts\Auth\Authenticatable, null given

if I am using the code below in my LoginController:

$user = User::where('USER_NAME', '=', $_GET['UserName'])->first();
if(Auth::login($user)->USER_ID == $_GET['UserName']){
   return redirect('Home');
}

And if I am using the code below in my LoginController:

if(Auth::attempt(['USER_ID' => $_GET['UserName']])){
   return redirect('Home');
}

I have got an error:

Undefined index: password



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire