You are here

public function UserAuthenticator::associateNewProvider in Social Auth 3.x

Same name and namespace in other branches
  1. 8.2 src/User/UserAuthenticator.php \Drupal\social_auth\User\UserAuthenticator::associateNewProvider()

Associates an existing user with a new provider.

Parameters

string $provider_user_id: The unique id returned by the user.

string $token: The access token for making additional API calls.

array|null $data: The additional user_data to be stored in database.

1 call to UserAuthenticator::associateNewProvider()
UserAuthenticator::authenticateUser in src/User/UserAuthenticator.php
Creates and/or authenticates an user.

File

src/User/UserAuthenticator.php, line 172

Class

UserAuthenticator
Manages Drupal authentication tasks for Social Auth.

Namespace

Drupal\social_auth\User

Code

public function associateNewProvider($provider_user_id, $token, $data) {
  if ($this->userManager
    ->addUserRecord($this->currentUser
    ->id(), $provider_user_id, $token, $data)) {
    $this->response = $this
      ->getPostLoginRedirection();
    return;
  }
  $this->messenger
    ->addError($this
    ->t('New provider could not be associated.'));
  $this->response = $this
    ->getLoginFormRedirection();
}