You are here

public function UserIdentityProvider::getUserEntityByIdentifier in Simple OAuth (OAuth2) & OpenID Connect 5.x

File

src/OpenIdConnect/UserIdentityProvider.php, line 35

Class

UserIdentityProvider
A user identity provider for the OpenID Connect integration.

Namespace

Drupal\simple_oauth\OpenIdConnect

Code

public function getUserEntityByIdentifier($identifier) {
  $user = $this->entityTypeManager
    ->getStorage('user')
    ->load($identifier);
  assert($user instanceof UserInterface);
  $user_entity = new UserEntityWithClaims();
  $user_entity
    ->setIdentifier($identifier);
  $claims = \Drupal::service('serializer')
    ->normalize($user_entity, 'json', [
    $identifier => $user,
  ]);
  $user_entity
    ->setClaims($claims);
  return $user_entity;
}