You are here

public function SamlUserService::findUidByUniqueId in SAML Authentication 8

Find a user by a given SAML unique ID.

Parameters

string $id: The unique ID to search for.

Return value

integer|null The uid of the matching user or NULL if we can't find one.

1 call to SamlUserService::findUidByUniqueId()
SamlUserService::handleSamlData in src/SamlUserService.php
Take appropriate action on provided SAML data.

File

src/SamlUserService.php, line 54
Contains Drupal\samlauth\SamlService.

Class

SamlUserService
Class SamlUserService.

Namespace

Drupal\samlauth

Code

public function findUidByUniqueId($id) {
  $return = $this->user_data
    ->get('samlauth', NULL, 'saml_id', $id);
  if (empty($return)) {
    $return = NULL;
  }
  elseif (is_array($return)) {
    if (count($return) === 1) {
      $return = reset($return);
    }
    else {
      throw new Exception('There are duplicates of the unique ID.');
    }
  }
  return $return;
}