A
A
Alexander Ampleev2019-12-13 14:43:24
Facebook
Alexander Ampleev, 2019-12-13 14:43:24

How to return the user to the same url from which he started authorization through facebook in laravel socilite?

Authorization via facebook works fine, but there is a problem - the user is always returned to a specific url from the callback method:

public function callback(SocialFacebookAccountService $service)
    {

        $user = Socialite::driver('facebook')->user();
        $facebookId = $user->getId();
        $user = $service->createOrGetUser($user);
        auth()->login($user);
        return redirect()->intended('/blog');
        
    }

The entire implementation was done exactly according to this article:
https://medium.com/@confidenceiyke/laravel-5-8-fac...
Thank you in advance for your advice.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nikolai Smirnov, 2019-12-13
@Bzdykin

You need to use the http request section Retrieving The Request Path $uri = $request->path();
Then use redirect
First try this in the callback() method, and if it doesn't work, then select the path in the redirect() method of the SocialAuthFacebookController class and pass it to the callback() method, and there already redirect to the given path.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question