Skip to content

Commit

Permalink
chg: [internal] authkey adding, more elegant solution
Browse files Browse the repository at this point in the history
  • Loading branch information
iglocska committed Nov 28, 2024
1 parent cfceaf0 commit 0ed3bef
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/Controller/AuthKeysController.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,14 @@ public function add()
$userConditions['id'] = $currentUser['id'];
} else {
$role_ids = $this->Users->Roles->find()->where(['perm_admin' => 0, 'perm_community_admin' => 0, 'perm_org_admin' => 0])->all()->extract('id')->toList();
if (empty($role_ids)) {
throw new MethodNotAllowedException(__('You are not authorised to do that, as there are no roles that you could assign to a user. Contact your administrator to rectify this.'));
}
$userConditions['organisation_id'] = $currentUser['organisation_id'];
$userConditions['OR'] = [
['role_id IN' => $role_ids],
['id' => $currentUser['id']],
$subConditions = [
['id' => $currentUser['id']]
];
if (!empty($role_ids)) {
$subConditions[] = ['role_id IN' => $role_ids];
}
$userConditions['OR'] = $subConditions;
}
}
$users = $this->Users->find('list');
Expand Down

0 comments on commit 0ed3bef

Please sign in to comment.