public function SimpleFbConnectController::redirectToFb in Simple FB Connect 8.3
Same name and namespace in other branches
- 8.2 src/Controller/SimpleFbConnectController.php \Drupal\simple_fb_connect\Controller\SimpleFbConnectController::redirectToFb()
Response for path 'user/simple-fb-connect'.
Redirects the user to FB for authentication.
1 string reference to 'SimpleFbConnectController::redirectToFb'
File
- src/
Controller/ SimpleFbConnectController.php, line 69
Class
- SimpleFbConnectController
- Returns responses for Simple FB Connect module routes.
Namespace
Drupal\simple_fb_connect\ControllerCode
public function redirectToFb() {
// Try to get an instance of Facebook service.
if (!($facebook = $this->fbFactory
->getFbService())) {
drupal_set_message($this
->t('Simple FB Connect is not configured properly. Please contact site administrator.'), 'error');
return $this
->redirect('user.login');
}
// Facebook service was returned, inject it to $fbManager.
$this->fbManager
->setFacebookService($facebook);
// Save post login path to session if it was set as a query parameter.
if ($post_login_path = $this->postLoginManager
->getPostLoginPathFromRequest()) {
$this->postLoginManager
->savePostLoginPath($post_login_path);
}
// Generate 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->fbManager
->getFbLoginUrl();
if ($this->persistentDataHandler
->get('reprompt')) {
$fb_login_url = $this->fbManager
->getFbReRequestUrl();
}
return new TrustedRedirectResponse($fb_login_url);
}