public function userLoginCallback() {
    $sdk = $this->getSdk('login');

    if ($sdk instanceof RedirectResponse) {
      return $sdk;
    }

    $this->authManager->setSdk($sdk);
    $profile = $this->getProfile('login');

    if ($profile instanceof RedirectResponse) {
      return $profile;
    }

    // Check whether user account exists.
    $account = $this->entityTypeManager()
      ->getStorage('user')
      ->loadByProperties([
        'linkedin_id' => $profile['id'],
      ]);

    if (!$account) {
      return $this->redirect('social_auth_linkedin.user_login_notice');
    }

    $account = current($account);

    if (!$account->get('status')->value) {
      drupal_set_message($this->t('Your account is blocked. Contact the site administrator.'), 'error');
      return $this->redirect('user.login');
    }

    // Authorize the user and redirect him to the account page.
    user_login_finalize($account);

    return $this->redirect('entity.user.canonical', [
      'user' => $account->id(),
    ]);
  }
public function userLoginCallback() {
    $sdk = $this->getSdk('login');

    if ($sdk instanceof RedirectResponse) {
      return $sdk;
    }

    $this->authManager->setSdk($sdk);
    $profile = $this->getProfile('login');

    if ($profile instanceof RedirectResponse) {
      return $profile;
    }

    // Check whether user account exists.
    $account = $this->entityTypeManager()
      ->getStorage('user')
      ->loadByProperties([
        'linkedin_id' => $profile['id'],
      ]);

    if (!$account) {
      return $this->redirect('social_auth_linkedin.user_login_notice');
    }

    $account = current($account);

    if (!$account->get('status')->value) {
      drupal_set_message($this->t('Your account is blocked. Contact the site administrator.'), 'error');
      return $this->redirect('user.login');
    }

    // Authorize the user and redirect him to the account page.
    user_login_finalize($account);

    return $this->redirect('entity.user.canonical', [
      'user' => $account->id(),
    ]);
  }
public function userLoginCallback ( ) { $ sdk = $ this -> getSdk ( 'login' ) ; if ( $ sdk instanceof RedirectResponse ) { return $ sdk ; } $ this -> authManager -> setSdk ( $ sdk ) ; $ profile = $ this -> getProfile ( 'login' ) ; if ( $ profile instanceof RedirectResponse ) { return $ profile ; } // Check whether user account exists. $ account = $ this -> entityTypeManager ( ) -> getStorage ( 'user' ) -> loadByProperties ( [ 'linkedin_id' => $ profile [ 'id' ] , ] ) ; if ( ! $ account ) { return $ this -> redirect ( 'social_auth_linkedin.user_login_notice' ) ; } $ account = current ( $ account ) ; if ( ! $ account -> get ( 'status' ) -> value ) { drupal_set_message ( $ this -> t ( 'Your account is blocked. Contact the site administrator.' ) , 'error' ) ; return $ this -> redirect ( 'user.login' ) ; } // Authorize the user and redirect him to the account page. user_login_finalize ( $ account ) ; return $ this -> redirect ( 'entity.user.canonical' , [ 'user' => $ account -> id ( ) , ] ) ; }
Authorizes the user after redirect from LinkedIn.

@return \Symfony\Component\HttpFoundation\RedirectResponse
Returns a RedirectResponse.
Authorizes the user after redirect from LinkedIn .