You are here

public function TokenAuthUser::__construct in Simple OAuth (OAuth2) & OpenID Connect 8

Same name and namespace in other branches
  1. 8.4 src/Authentication/TokenAuthUser.php \Drupal\simple_oauth\Authentication\TokenAuthUser::__construct()
  2. 8.2 src/Authentication/TokenAuthUser.php \Drupal\simple_oauth\Authentication\TokenAuthUser::__construct()
  3. 8.3 src/Authentication/TokenAuthUser.php \Drupal\simple_oauth\Authentication\TokenAuthUser::__construct()
  4. 5.x src/Authentication/TokenAuthUser.php \Drupal\simple_oauth\Authentication\TokenAuthUser::__construct()

Constructs a TokenAuthUser object.

Parameters

AccessTokenInterface $token: The underlying token.

Throws

\Exception When there is no user.

File

src/Authentication/TokenAuthUser.php, line 49

Class

TokenAuthUser
Class TokenAuthUser.

Namespace

Drupal\simple_oauth\Authentication

Code

public function __construct(AccessTokenInterface $token) {
  if (!($this->subject = $token
    ->get('auth_user_id')->entity)) {
    throw new \Exception('The access token does not link to a user.');
  }
  $this->token = $token;
}