You are here

public function ExternalAuth::loginRegister in External Authentication 8

Same name and namespace in other branches
  1. 2.0.x src/ExternalAuth.php \Drupal\externalauth\ExternalAuth::loginRegister()

Login and optionally register a Drupal user based on an external authname.

Parameters

string $authname: The unique, external authentication name provided by authentication provider.

string $provider: The module providing external authentication.

array $account_data: An array of additional properties to be saved with the user entity.

mixed $authmap_data: Additional data to be stored in the authmap entry.

Return value

\Drupal\user\UserInterface The logged in, and optionally registered, Drupal user.

Overrides ExternalAuthInterface::loginRegister

File

src/ExternalAuth.php, line 148

Class

ExternalAuth
Class ExternalAuth.

Namespace

Drupal\externalauth

Code

public function loginRegister($authname, $provider, array $account_data = [], $authmap_data = NULL) {
  $account = $this
    ->login($authname, $provider);
  if (!$account) {
    $account = $this
      ->register($authname, $provider, $account_data, $authmap_data);
    return $this
      ->userLoginFinalize($account, $authname, $provider);
  }
  return $account;
}