function UserAuthentication::lookupAccount

Same name and namespace in other branches
  1. 11.x core/modules/user/src/UserAuthentication.php \Drupal\user\UserAuthentication::lookupAccount()

Validates user authentication credentials.

Parameters

string $identifier: The user identifier to authenticate. Usually the username.

Return value

Drupal\User\UserInterface|false The user account on success, or FALSE on failure to authenticate.

Overrides UserAuthenticationInterface::lookupAccount

File

core/modules/user/src/UserAuthentication.php, line 62

Class

UserAuthentication
Validates user authentication credentials.

Namespace

Drupal\user

Code

public function lookupAccount($identifier) : UserInterface|false {
  if (!empty($identifier)) {
    $account_search = $this->entityTypeManager
      ->getStorage('user')
      ->loadByProperties([
      'name' => $identifier,
    ]);
    if ($account = reset($account_search)) {
      return $account;
    }
  }
  return FALSE;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.