You are here

public function CustomAccessCheck::access in OAuth 1.0 8.2

Check if the user can administer their own keys, or has the 'administer consumer' permission.

Parameters

\Drupal\Core\User\UserInterface:

\Drupal\Core\Session\AccountInterface $account: Run access checks for this account.

Return value

bool

File

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

Class

CustomAccessCheck
Checks access for oauth.

Namespace

Drupal\oauth\Access

Code

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')));
}