You are here

public function DrupalUserProcessor::newDrupalUserCreated in Lightweight Directory Access Protocol (LDAP) 8.3

Callback for hook_ENTITY_TYPE_insert().

Perform any actions required, due to possibly not being the module creating the user.

Parameters

\Drupal\user\UserInterface $account: The Drupal user.

File

ldap_user/src/Processor/DrupalUserProcessor.php, line 508

Class

DrupalUserProcessor
Handles processing of a user from LDAP to Drupal.

Namespace

Drupal\ldap_user\Processor

Code

public function newDrupalUserCreated(UserInterface $account) {
  $this->account = $account;
  if (ExternalAuthenticationHelper::excludeUser($account)) {
    return;
  }
  if (is_object($account) && $account
    ->getAccountName()) {

    // Check for first time user.
    if (SemaphoreStorage::get('provision', $account
      ->getAccountName()) || SemaphoreStorage::get('sync', $account
      ->getAccountName()) || $this
      ->newAccountRequest($account)) {
      return;
    }
  }

  // The account is already created, so do not provisionDrupalAccount(), just
  // syncToDrupalAccount(), even if action is 'provision'.
  if ($account
    ->isActive() && LdapConfiguration::provisionAvailableToDrupal(self::PROVISION_DRUPAL_USER_ON_USER_UPDATE_CREATE)) {
    $this
      ->syncToDrupalAccount(self::EVENT_CREATE_DRUPAL_USER);
  }
  $this
    ->provisionLdapEntryOnUserCreation($account);
}