public function FacebookAuthController::userRegisterCallback 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::userRegisterCallback()
- 8.2 modules/custom/social_auth_facebook/src/Controller/FacebookAuthController.php \Drupal\social_auth_facebook\Controller\FacebookAuthController::userRegisterCallback()
- 8.3 modules/custom/social_auth_facebook/src/Controller/FacebookAuthController.php \Drupal\social_auth_facebook\Controller\FacebookAuthController::userRegisterCallback()
- 8.4 modules/custom/social_auth_facebook/src/Controller/FacebookAuthController.php \Drupal\social_auth_facebook\Controller\FacebookAuthController::userRegisterCallback()
- 8.5 modules/custom/social_auth_facebook/src/Controller/FacebookAuthController.php \Drupal\social_auth_facebook\Controller\FacebookAuthController::userRegisterCallback()
- 8.6 modules/custom/social_auth_facebook/src/Controller/FacebookAuthController.php \Drupal\social_auth_facebook\Controller\FacebookAuthController::userRegisterCallback()
- 8.7 modules/custom/social_auth_facebook/src/Controller/FacebookAuthController.php \Drupal\social_auth_facebook\Controller\FacebookAuthController::userRegisterCallback()
- 8.8 modules/custom/social_auth_facebook/src/Controller/FacebookAuthController.php \Drupal\social_auth_facebook\Controller\FacebookAuthController::userRegisterCallback()
Registers the new account after redirect from Facebook.
Return value
\Symfony\Component\HttpFoundation\RedirectResponse Return a RedirectResponse.
1 string reference to 'FacebookAuthController::userRegisterCallback'
- social_auth_facebook.routing.yml in modules/
custom/ social_auth_facebook/ social_auth_facebook.routing.yml - modules/custom/social_auth_facebook/social_auth_facebook.routing.yml
File
- modules/
custom/ social_auth_facebook/ src/ Controller/ FacebookAuthController.php, line 142
Class
- FacebookAuthController
- Class FacebookAuthController.
Namespace
Drupal\social_auth_facebook\ControllerCode
public function userRegisterCallback() {
$sdk = $this
->getSdk('register');
if ($sdk instanceof RedirectResponse) {
return $sdk;
}
$this->authManager
->setSdk($sdk);
$profile = $this
->getProfile('register');
if ($profile instanceof RedirectResponse) {
return $profile;
}
// Check whether user account exists. If account already exists,
// authorize the user and redirect him to the account page.
$account = $this
->entityTypeManager()
->getStorage('user')
->loadByProperties([
'facebook_id' => $profile
->getField('id'),
]);
if ($account) {
$account = current($account);
if (!$account
->get('status')->value) {
drupal_set_message($this
->t('You already have account on this site, but your account is blocked. Contact the site administrator.'), 'error');
return $this
->redirect('user.register');
}
user_login_finalize($account);
return $this
->redirect('entity.user.canonical', [
'user' => $account
->id(),
]);
}
// Save email and name to storage to use for auto fill the registration
// form.
$data_handler = $this->networkManager
->createInstance('social_auth_facebook')
->getDataHandler();
$data_handler
->set('access_token', $this->accessToken);
$data_handler
->set('mail', $profile
->getField('email'));
$data_handler
->set('name', $profile
->getField('name'));
drupal_set_message($this
->t('You are now connected with @network, please continue registration', [
'@network' => $this
->t('Facebook'),
]));
return $this
->redirect('user.register', [
'provider' => 'facebook',
]);
}