You are here

public function SimplesamlphpDrupalAuth::externalLoginRegister in simpleSAMLphp Authentication 8.3

Log in and optionally register a user based on the authname provided.

Parameters

string $authname: The authentication name.

Return value

\Drupal\Core\Entity\EntityInterface|null The logged in Drupal user.

File

src/Service/SimplesamlphpDrupalAuth.php, line 118

Class

SimplesamlphpDrupalAuth
Service to link SimpleSAMLphp authentication with Drupal users.

Namespace

Drupal\simplesamlphp_auth\Service

Code

public function externalLoginRegister($authname) {
  $account = $this->externalauth
    ->login($authname, 'simplesamlphp_auth');
  if (!$account) {
    $account = $this
      ->externalRegister($authname);
  }
  if ($account) {

    // Determine if roles should be evaluated upon login.
    if ($this->config
      ->get('role.eval_every_time')) {
      $this
        ->roleMatchSync($account);
    }
  }
  return $account;
}