You are here

public function OpenIDConnect::hasSetPasswordAccess in OpenID Connect / OAuth client 8

Same name and namespace in other branches
  1. 2.x src/OpenIDConnect.php \Drupal\openid_connect\OpenIDConnect::hasSetPasswordAccess()

Find whether a user is allowed to change the own password.

Parameters

\Drupal\Core\Session\AccountInterface $account: Optional: Account to check the access for. Defaults to the currently logged-in user.

Return value

bool TRUE if access is granted, FALSE otherwise.

File

src/OpenIDConnect.php, line 468

Class

OpenIDConnect
Main service of the OpenID Connect module.

Namespace

Drupal\openid_connect

Code

public function hasSetPasswordAccess(AccountInterface $account = NULL) {
  if (empty($account)) {
    $account = $this->currentUser;
  }
  if ($account
    ->hasPermission('openid connect set own password')) {
    return TRUE;
  }
  $connected_accounts = $this->authmap
    ->getConnectedAccounts($account);
  return empty($connected_accounts);
}