You are here

public function RevocableTokenRepositoryTrait::revoke in Simple OAuth (OAuth2) & OpenID Connect 8.3

Same name and namespace in other branches
  1. 8.4 src/Repositories/RevocableTokenRepositoryTrait.php \Drupal\simple_oauth\Repositories\RevocableTokenRepositoryTrait::revoke()
  2. 8.2 src/Repositories/RevocableTokenRepositoryTrait.php \Drupal\simple_oauth\Repositories\RevocableTokenRepositoryTrait::revoke()
  3. 5.x src/Repositories/RevocableTokenRepositoryTrait.php \Drupal\simple_oauth\Repositories\RevocableTokenRepositoryTrait::revoke()
3 calls to RevocableTokenRepositoryTrait::revoke()
AccessTokenRepository::revokeAccessToken in src/Repositories/AccessTokenRepository.php
AuthCodeRepository::revokeAuthCode in simple_oauth_extras/src/Repositories/AuthCodeRepository.php
RefreshTokenRepository::revokeRefreshToken in src/Repositories/RefreshTokenRepository.php

File

src/Repositories/RevocableTokenRepositoryTrait.php, line 72

Class

RevocableTokenRepositoryTrait
Common methods for token repositories on different grants.

Namespace

Drupal\simple_oauth\Repositories

Code

public function revoke($token_id) {
  if (!($tokens = $this->entityTypeManager
    ->getStorage(static::$entity_type_id)
    ->loadByProperties([
    'value' => $token_id,
  ]))) {
    return;
  }

  /** @var \Drupal\simple_oauth\Entity\Oauth2TokenInterface $token */
  $token = reset($tokens);
  $token
    ->revoke();
  $token
    ->save();
}