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',
    ]);
  }
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',
    ]);
  }
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' , ] ) ; }
Registers the new account after redirect from Facebook.

@return \Symfony\Component\HttpFoundation\RedirectResponse
Return a RedirectResponse.
Registers the new account after redirect from Facebook .