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.