Logging a user in manually on Laravel 5

I’m using facebook JS to log in users to a laravel 5 application.
I’m able to add the information to the database correctly but I’m trying to log the user in manually and can’t figure it out.

Here is my controller:

    <?php namespace AppHttpControllers;

use AppHttpRequests;
use AppHttpControllersController;
use IlluminateHttpRequest;
use AppHttplibTopAdditions;
use AppHttplibGeneralFunctions;
use AppUser;

class FacebookLoginController extends Controller{
    public function FacebookRegistration(){


        $facebook = new User();
        $isThereAUser = User::where('name', $_GET['name'])->get();

        if(!count($isThereAUser) > 0){
            $facebook->name = $_GET['name'];
            $facebook->email = $_GET['email'];
            $facebook->password = sha1($_GET['password']);
            $facebook->remember_token = $_GET['token'];
            $facebook->save();

            $id = User::where('name', $_GET['name'])->get();
            $this->LoginUser($id);

        }

    }

    public function LoginUser($id){

        Auth::login($id[0]['id'],true);



    }
}

When I run that and there is no such user in the database, the user is created and I get this message when the manual login is attempted:

ErrorException in Guard.php line 425:
Argument 1 passed to IlluminateAuthGuard::login() must implement interface IlluminateContractsAuthAuthenticatable, integer given

I’ve been searching the web for similar situations but couldn’t find anything that will help…

Please help me!


Source: facebook

Leave a Reply