Home How to redirect the user to login to facebook and have them come back to the same place?
Reply: 0

How to redirect the user to login to facebook and have them come back to the same place?

user1100
1#
user1100 Published in May 20, 2018, 12:03 pm

I have a dashboard feature that requires facebook login. If the token is expired, I catch that.

So far so good, however, I'd like the user to go off to login and come back to the same place.

This is the code:

try {
    //make FB client
    $fb = new Facebook( [
        'app_id'                => config( 'app.FACEBOOK_APPID' ),
        'app_secret'            => config( 'app.FACEBOOK_APPSECRET' ),
            'default_graph_version' => 'v2.8',
    ] );

    //Pull events realted to this user
    $events      = $fb->get( $endpoint, $accessToken )->getDecodedBody();

//catch exception if token is expired
} catch ( FacebookSDKException $e ) {
    //redirect to facebook login
    return redirect()->action('Auth\SocialiteLoginController@redirectToProvider', ['facebook']);
}
return $events;

My issue is, the return redirect() statement, does not redirect the user to Facebook, but, it sends back the RedirectResponse object to the calling function.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.306506 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO