You are here

class EditOwnUserAccountAccessCheck in Edit own user account permission 8

Hierarchy

Expanded class hierarchy of EditOwnUserAccountAccessCheck

File

src/Access/EditOwnUserAccountAccessCheck.php, line 9

Namespace

Drupal\edit_own_user_account_permission\Access
View source
class EditOwnUserAccountAccessCheck implements AccessInterface {

  /**
   * Checks access for editing own user account while current user being the
   * target account.
   *
   * @param AccountInterface $user
   *   The user account that is to be edited.
   * @param AccountInterface $account
   *   User account that is from the current session.
   * @return AccessResult
   */
  public function access(AccountInterface $user, AccountInterface $account) {
    $can_edit_own_account = $account
      ->hasPermission('edit own user account') && $user
      ->id() == $account
      ->id();
    return AccessResult::allowedIf($can_edit_own_account || $account
      ->hasPermission('administer users'));
  }

}

Members

Namesort descending Modifiers Type Description Overrides
EditOwnUserAccountAccessCheck::access public function Checks access for editing own user account while current user being the target account.