You are here

protected function ClientCredentialsOverrideGrant::getDefaultUser in Simple OAuth (OAuth2) & OpenID Connect 8.4

Same name and namespace in other branches
  1. 5.x src/Grant/ClientCredentialsOverrideGrant.php \Drupal\simple_oauth\Grant\ClientCredentialsOverrideGrant::getDefaultUser()

Finds the default user for the client.

Parameters

\League\OAuth2\Server\Entities\ClientEntityInterface $client: The League's client.

Return value

\Drupal\user\Entity\User The default user.

Throws

\Drupal\Component\Plugin\Exception\PluginException

1 call to ClientCredentialsOverrideGrant::getDefaultUser()
ClientCredentialsOverrideGrant::respondToAccessTokenRequest in src/Grant/ClientCredentialsOverrideGrant.php

File

src/Grant/ClientCredentialsOverrideGrant.php, line 59

Class

ClientCredentialsOverrideGrant
Injects the user information in the client credentials token.

Namespace

Drupal\simple_oauth\Grant

Code

protected function getDefaultUser(ClientEntityInterface $client) {
  $client_drupal_entities = \Drupal::entityTypeManager()
    ->getStorage('consumer')
    ->loadByProperties([
    'uuid' => $client
      ->getIdentifier(),
  ]);
  $client_drupal_entity = reset($client_drupal_entities);
  return $client_drupal_entity ? $client_drupal_entity
    ->get('user_id')->target_id : NULL;
}