You are here

public function OpenIDConnectAccountsForm::access in OpenID Connect / OAuth client 2.x

Same name and namespace in other branches
  1. 8 src/Form/OpenIDConnectAccountsForm.php \Drupal\openid_connect\Form\OpenIDConnectAccountsForm::access()

Checks access for the OpenID-Connect accounts form.

Parameters

\Drupal\Core\Session\AccountInterface $user: The user having accounts.

Return value

\Drupal\Core\Access\AccessResultInterface The access result.

1 string reference to 'OpenIDConnectAccountsForm::access'
openid_connect.routing.yml in ./openid_connect.routing.yml
openid_connect.routing.yml

File

src/Form/OpenIDConnectAccountsForm.php, line 207

Class

OpenIDConnectAccountsForm
Provides the user-specific OpenID Connect settings form.

Namespace

Drupal\openid_connect\Form

Code

public function access(AccountInterface $user) : AccessResultInterface {
  if ($this->currentUser
    ->hasPermission('administer users')) {
    return AccessResult::allowed();
  }
  if ($this->currentUser
    ->id() && $this->currentUser
    ->id() === $user
    ->id() && $this->currentUser
    ->hasPermission('manage own openid connect accounts')) {
    return AccessResult::allowed();
  }
  return AccessResult::forbidden();
}