public function FacebookAuthController::getProfile in Open Social 8
Same name and namespace in other branches
- 8.9 modules/custom/social_auth_facebook/src/Controller/FacebookAuthController.php \Drupal\social_auth_facebook\Controller\FacebookAuthController::getProfile()
- 8.2 modules/custom/social_auth_facebook/src/Controller/FacebookAuthController.php \Drupal\social_auth_facebook\Controller\FacebookAuthController::getProfile()
- 8.3 modules/custom/social_auth_facebook/src/Controller/FacebookAuthController.php \Drupal\social_auth_facebook\Controller\FacebookAuthController::getProfile()
- 8.4 modules/custom/social_auth_facebook/src/Controller/FacebookAuthController.php \Drupal\social_auth_facebook\Controller\FacebookAuthController::getProfile()
- 8.5 modules/custom/social_auth_facebook/src/Controller/FacebookAuthController.php \Drupal\social_auth_facebook\Controller\FacebookAuthController::getProfile()
- 8.6 modules/custom/social_auth_facebook/src/Controller/FacebookAuthController.php \Drupal\social_auth_facebook\Controller\FacebookAuthController::getProfile()
- 8.7 modules/custom/social_auth_facebook/src/Controller/FacebookAuthController.php \Drupal\social_auth_facebook\Controller\FacebookAuthController::getProfile()
- 8.8 modules/custom/social_auth_facebook/src/Controller/FacebookAuthController.php \Drupal\social_auth_facebook\Controller\FacebookAuthController::getProfile()
Loads access token, then loads profile.
Parameters
string $type: The type.
Return value
object Returns an object.
2 calls to FacebookAuthController::getProfile()
- FacebookAuthController::userLoginCallback in modules/
custom/ social_auth_facebook/ src/ Controller/ FacebookAuthController.php - Authorizes the user after redirect from Facebook.
- FacebookAuthController::userRegisterCallback in modules/
custom/ social_auth_facebook/ src/ Controller/ FacebookAuthController.php - Registers the new account after redirect from Facebook.
File
- modules/
custom/ social_auth_facebook/ src/ Controller/ FacebookAuthController.php, line 232
Class
- FacebookAuthController
- Class FacebookAuthController.
Namespace
Drupal\social_auth_facebook\ControllerCode
public function getProfile($type) {
// Get the OAuth token from Facebook.
if (!($access_token = $this->authManager
->getAccessToken($type))) {
drupal_set_message($this
->t('@network login failed. Token is not valid.', [
'@network' => $this
->t('Facebook'),
]), 'error');
return $this
->redirect('user.' . $type);
}
// Get user's Facebook profile from Facebook API.
if (!($profile = $this->authManager
->getProfile()) || !$profile
->getField('id')) {
drupal_set_message($this
->t('@network login failed, could not load @network profile. Contact the site administrator.', [
'@network' => $this
->t('Facebook'),
]), 'error');
return $this
->redirect('user.' . $type);
}
$this->accessToken = $access_token;
return $profile;
}