You are here

protected function SocialAuthUserManager::getUserFields in Social Auth 8

Returns an array of fields to initialize the creation of the user.

Parameters

string $name: User's name on Provider.

string $email: User's email address.

string $langcode: The current UI language.

Return value

array Fields to initialize for the user creation.

1 call to SocialAuthUserManager::getUserFields()
SocialAuthUserManager::createUser in src/SocialAuthUserManager.php
Create a new user account.

File

src/SocialAuthUserManager.php, line 734

Class

SocialAuthUserManager
Contains all logic that is related to Drupal user management.

Namespace

Drupal\social_auth

Code

protected function getUserFields($name, $email, $langcode) {

  // - Password can be very long since the user doesn't see this.
  $fields = [
    'name' => $this
      ->generateUniqueUsername($name),
    'mail' => $email,
    'init' => $email,
    'pass' => $this
      ->userPassword(32),
    'status' => $this
      ->getNewUserStatus(),
    'langcode' => $langcode,
    'preferred_langcode' => $langcode,
    'preferred_admin_langcode' => $langcode,
  ];

  // Dispatches SocialAuthEvents::USER_FIELDS, so that other modules can
  // update this array before an user is saved.
  $event = new SocialAuthUserFieldsEvent($fields, $this
    ->getPluginId());
  $this->eventDispatcher
    ->dispatch(SocialAuthEvents::USER_FIELDS, $event);
  $fields = $event
    ->getUserFields();
  return $fields;
}