Hesto / multi-auth

Laravel 5.3, 5.4, 5.5, 5.6, 5.7 multi auth package
MIT License
448 stars 146 forks source link

Issue when using with Socialite #33

Open stryct911 opened 7 years ago

stryct911 commented 7 years ago

I am trying to use Socialite (facebook login in particular). Based on the setup instructions and any tutorials I have found, I get the following error:

Argument 1 passed to Illuminate\Auth\SessionGuard::login() must be an instance of Illuminate\Contracts\Auth\Authenticatable, instance of Laravel\Socialite\Two\User given, called in xxxxx/vendor/laravel/framework/src/Illuminate/Auth/AuthManager.php on line 294 and defined

Is it possible, the two can work togeather?

Hesto commented 7 years ago

Im not sure if Socialite can work with custom guards. Never tried it but when i find some time i will try to make it work. When i look into Socialite doc's i think it should work. Did you add methods from docs to your guard's AuthController?

/**
     * Redirect the user to the GitHub authentication page.
     *
     * @return Response
     */
    public function redirectToProvider()
    {
        return Socialite::driver('github')->redirect();
    }

    /**
     * Obtain the user information from GitHub.
     *
     * @return Response
     */
    public function handleProviderCallback()
    {
        $user = Socialite::driver('github')->user();

        // $user->token;
    }
stryct911 commented 7 years ago

Yes, it returns back correctly, its failing on logging in.

angeloo commented 7 years ago

Don't forget:

/**
     * Obtain the user information from GitHub.
     *
     * @return Response
     */
public function handleProviderCallback($provider)
    {
        $user = Socialite::driver($provider)->user();

        $authUser = $this->findOrCreateUser($user, $provider);
        Auth::guard('admin')->login($authUser, true);
        return redirect($this->redirectTo);
    }

If your guard is admin

satrasot commented 7 years ago

Its not working for me when Auth::guard('admin')->login($authUser, true)

sunewa commented 7 years ago

Its not working for me too