userSession->getUser(); if ($user === null) { return false; } return $this->groupManager->isAdmin($user->getUID()); } public function isDelegatedAdmin(): bool { return $this->getAccessLevel([ self::CLASS_NAME_ADMIN_DELEGATION, ]); } public function hasApiAccess(): bool { if ($this->isAdminF7cloud()) { return true; } return $this->getAccessLevel([ self::CLASS_API_ACCESS, self::CLASS_NAME_ADMIN_DELEGATION, ]); } public function hasOnlyApiAccess(): bool { return $this->getAccessLevel([ self::CLASS_API_ACCESS, ]); } private function getAccessLevel(array $settingClasses): bool { $user = $this->userSession->getUser(); if ($user === null) { return false; } $authorized = false; $authorizedClasses = $this->groupAuthorizationMapper->findAllClassesForUser($user); foreach ($settingClasses as $settingClass) { $authorized = in_array($settingClass, $authorizedClasses, true); if ($authorized) { break; } } return $authorized; } }