You are here

class CustomAccessCheck in OAuth 1.0 8.2

Checks access for oauth.

Hierarchy

Expanded class hierarchy of CustomAccessCheck

1 string reference to 'CustomAccessCheck'
oauth.services.yml in ./oauth.services.yml
oauth.services.yml
1 service uses CustomAccessCheck
oauth.access_checker in ./oauth.services.yml
Drupal\oauth\Access\CustomAccessCheck

File

src/Access/CustomAccessCheck.php, line 17
Contains \Drupal\example\Access\CustomAccessCheck.

Namespace

Drupal\oauth\Access
View source
class CustomAccessCheck implements AccessInterface {

  /**
   * Check if the user can administer their own keys, or has the 'administer
   * consumer' permission.
   *
   * @param \Drupal\Core\User\UserInterface
   * @param \Drupal\Core\Session\AccountInterface $account
   *   Run access checks for this account.
   * @return bool
   */
  public function access(UserInterface $user, AccountInterface $account) {
    return AccessResult::allowedIfHasPermission($account, 'administer consumers')
      ->orIf(AccessResult::allowedIf($user
      ->id() == $account
      ->id())
      ->addCacheableDependency($account)
      ->andIf(AccessResult::allowedIfHasPermission($account, 'access own consumers')));
  }

}

Members

Namesort descending Modifiers Type Description Overrides
CustomAccessCheck::access public function Check if the user can administer their own keys, or has the 'administer consumer' permission.