E
E
Enma2020-07-15 12:52:17
Laravel
Enma, 2020-07-15 12:52:17

How to get authorized user after Laravel Socialite callback?

Good afternoon! I have a Laravel and ReactJS application (not create-react-app).

I log in to Facebook using Laravel Socialite, then in the callback function I create a user and immediately authorize him.

public function handleProviderCallback($provider)
    {
        $socialiteUser = Socialite::driver($provider)->user();
        $user = $this->findOrCreateUser($provider, $socialiteUser);
        Auth::login($user, true);
    }


further, I dump the current authorized user, Auth::user() and get null.
Why? And how to solve this issue?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Enma, 2020-09-14
@Enma

in general, suddenly someone will need it in the future.
if you use ReactJS in conjunction, then you won’t be able to authorize users through the Auth facade, use jwt, sanctum, etc.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question