You are here

public function Authmap::getUid in External Authentication 8

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

Get a Drupal user ID based on an authname.

The authname will be provided by an authentication provider.

Parameters

string $authname: The external authname as provided by the authentication provider.

string $provider: The name of the service providing external authentication.

Return value

int|bool The Drupal user ID or FALSE.

Overrides AuthmapInterface::getUid

File

src/Authmap.php, line 108

Class

Authmap
Class Authmap.

Namespace

Drupal\externalauth

Code

public function getUid($authname, $provider) {
  $authname = $this->connection
    ->select('authmap', 'am')
    ->fields('am', [
    'uid',
  ])
    ->condition('authname', $authname)
    ->condition('provider', $provider)
    ->range(0, 1)
    ->execute()
    ->fetchObject();
  if ($authname) {
    return $authname->uid;
  }
  return FALSE;
}