diff --git a/src/Controller/Component/ACLComponent.php b/src/Controller/Component/ACLComponent.php index fb51f49..7592908 100644 --- a/src/Controller/Component/ACLComponent.php +++ b/src/Controller/Component/ACLComponent.php @@ -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; } /*