new: [ACL] added canEditUser() function
- simple comparison between two users - checks role + org based permissioncli-modification-summary
parent
19c81b7c11
commit
9a0ddef2af
|
@ -277,9 +277,29 @@ class ACLComponent extends Component
|
||||||
$this->user = $user;
|
$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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in New Issue