new: [ACL] added canEditUser() function

- simple comparison between two users
- checks role + org based permission
cli-modification-summary
iglocska 2022-01-26 14:16:28 +01:00
parent 19c81b7c11
commit 9a0ddef2af
No known key found for this signature in database
GPG Key ID: BEA224F1FEF113AC
1 changed files with 22 additions and 2 deletions

View File

@ -277,9 +277,29 @@ class ACLComponent extends Component
$this->user = $user;
}
public function getUser(): User
public function getUser(): ?User
{
return $this->user;
if (!empty($this->user)) {
return $this->user;
}
return null;
}
public function canEditUser(User $currentUser, User $user): bool
{
if (empty($user) || empty($currentUser)) {
return false;
}
if (!$currentUser['role']['perm_admin']) {
if (!$currentUser['role']['perm_org_admin']) {
return false;
} else {
if ($currentUser['organisation_id'] !== $user['organisation_id']) {
return false;
}
}
}
return true;
}
/*