public function FacebookAuthController::redirectToFb in Social Auth Facebook 8
Response for path 'user/simple-fb-connect'.
Redirects the user to FB for authentication.
1 string reference to 'FacebookAuthController::redirectToFb'
File
- src/
Controller/ FacebookAuthController.php, line 102
Class
- FacebookAuthController
- Returns responses for Simple FB Connect module routes.
Namespace
Drupal\social_auth_facebook\ControllerCode
public function redirectToFb() {
/* @var \Facebook\Facebook|false $facebook */
$facebook = $this->networkManager
->createInstance('social_auth_facebook')
->getSdk();
// If facebook client could not be obtained.
if (!$facebook) {
drupal_set_message($this
->t('Social Auth Facebook not configured properly. Contact site administrator.'), 'error');
return $this
->redirect('user.login');
}
// Facebook service was returned, inject it to $fbManager.
$this->facebookManager
->setClient($facebook);
// Generates the URL where the user will be redirected for FB login.
// If the user did not have email permission granted on previous attempt,
// we use the re-request URL requesting only the email address.
$fb_login_url = $this->facebookManager
->getFbLoginUrl();
if ($this->persistentDataHandler
->get('reprompt')) {
$fb_login_url = $this->facebookManager
->getFbReRequestUrl();
}
return new TrustedRedirectResponse($fb_login_url);
}