fix: [OrgGroups:checkIfGroupAdmin] Consider site_admins as group admin

refacto/CRUDComponent
Sami Mokaddem 2023-09-12 14:31:03 +02:00
parent 44527bbcb8
commit b2df8192f7
No known key found for this signature in database
GPG Key ID: 164C473F627A06FA
2 changed files with 5 additions and 2 deletions

View File

@ -175,8 +175,8 @@ class ACLComponent extends Component
'listOrgs' => ['*'], 'listOrgs' => ['*'],
'assignAdmin' => ['perm_admin'], 'assignAdmin' => ['perm_admin'],
'removeAdmin' => ['perm_admin'], 'removeAdmin' => ['perm_admin'],
'attachOrg' => ['perm_group_admin'], 'attachOrg' => ['perm_admin', 'perm_group_admin'],
'detachOrg' => ['perm_group_admin'] 'detachOrg' => ['perm_admin', 'perm_group_admin']
], ],
'Organisations' => [ 'Organisations' => [
'add' => ['perm_admin'], 'add' => ['perm_admin'],

View File

@ -37,6 +37,9 @@ class OrgGroupsTable extends AppTable
public function checkIfGroupAdmin(int $groupId, User $user): bool public function checkIfGroupAdmin(int $groupId, User $user): bool
{ {
if (!empty($user['role']['perm_admin'])) {
return true;
}
$orgGroup = $this->get($groupId, ['contain' => 'Users']); $orgGroup = $this->get($groupId, ['contain' => 'Users']);
if (empty($orgGroup)) { if (empty($orgGroup)) {
return false; return false;