0
votes

I'm getting below error when trying login with google or Facebook.

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

i'm using socialite package for laravel. what is the problem, i'm unable to solve it.i'm first time using laravel Socialite package

use App\User;

use App\Http\Controllers\Controller;

use Illuminate\Auth\Events\Registered;

use Illuminate\Http\Request;

use Illuminate\Support\Facades\Validator;

use Illuminate\Foundation\Auth\RegistersUsers;

use Laravel\Socialite\Facades\Socialite;


class RegisterController extends Controller




{





protected function create(array $data)

    {
        return User::create([

            'name' => $data['name'],

            'email' => $data['email'],

            'password' => bcrypt($data['password']),

            'user_type' => 'user',

            'active_status' => '1'
        ]);
    }

    public function redirectToProvider()


    {

        return  Socialite::driver('facebook')->redirect();


    }

 public function handleProviderCallback()

    {



try{


$socialuser = Socialite::driver('facebook')->stateless()->user();



}  

catch(exception $e){


return redirect('/');

}

$user=User::where('facebook_id',$socialuser->getid())->first();

if(!$user)

User::create([

'facebook_id'=>$socialuser->getid(),

'email'=>$socialuser->getemail(),

'name'=>$socialuser->getname(),
    ]);

auth()->login($user);

    return redirect()->to('/dashboard');
    }
}

Please help me.i'm a beginner. Thanks

1
Please be more specific about what you're trying to do. Can you provide some code?oscfri

1 Answers

0
votes

Check your User model make sure it implements Authenticable. I'd guess it currently extends Model but doesn't use Authenticable. Post it here to let use confirm it looks ok.