Reputation: 2716
I'm trying to implement socialite but I am getting an error relating to the authenticator class. My app can not find it.
This is the code in my controller
<?php namespace App;
use Illuminate\Contracts\Auth\Authenticator;
use App\Repositories\UserRepository as UserRepository;
use Laravel\Socialite\Contracts\Factory as Socialite;
class AuthenticateUser {
private $users;
private $socialite;
private $auth;
public function __construct(UserRepository $users, Socialite $socialite, Authenticator $auth)
{
$this->users = $users;
$this->socialite = $socialite;
$this->auth = $auth;
}
public function execute($hasCode)
{
if ( ! $hasCode ) return $this->getAuthorisationFirst();
$user = $this->socialite->drivers('google')->user();
dd($user);
}
private function getAuthorisationFirst()
{
return $this->socialite->driver('google')->redirect();
}
}
The error I receive is
ReflectionException in Container.php line 833: Class Illuminate\Contracts\Auth\Authenticator does not exist
Upvotes: 2
Views: 1468
Reputation: 281
It seems that with laravel 5 the authenticator is now called Guard
The Authenticator was renamed to Guard. In the AuthenticateUser.php file rename 'use Illuminate\Contracts\Auth\Authenticator;' to 'use Illuminate\Contracts\Auth\Guard;' and don't forget to also change it in constructor function too" –
Upvotes: 6