parent
b0e06cd0f6
commit
0850c92e89
|
@ -308,6 +308,9 @@ class UsersController extends AppController
|
||||||
}
|
}
|
||||||
$params = [
|
$params = [
|
||||||
'beforeSave' => function($data) use ($currentUser, $validRoles) {
|
'beforeSave' => function($data) use ($currentUser, $validRoles) {
|
||||||
|
if (empty(Configure::read('user.allow-user-deletion'))) {
|
||||||
|
throw new MethodNotAllowedException(__('User deletion is disabled on this instance.'));
|
||||||
|
}
|
||||||
if (!$currentUser['role']['perm_admin']) {
|
if (!$currentUser['role']['perm_admin']) {
|
||||||
if ($data['organisation_id'] !== $currentUser['organisation_id']) {
|
if ($data['organisation_id'] !== $currentUser['organisation_id']) {
|
||||||
throw new MethodNotAllowedException(__('You do not have permission to delete the given user.'));
|
throw new MethodNotAllowedException(__('You do not have permission to delete the given user.'));
|
||||||
|
|
|
@ -342,7 +342,13 @@ class CerebrateSettingsProvider extends BaseSettingsProvider
|
||||||
'type' => 'boolean',
|
'type' => 'boolean',
|
||||||
'description' => __('This setting will enforce that usernames conform to basic requirements of e-mail addresses.'),
|
'description' => __('This setting will enforce that usernames conform to basic requirements of e-mail addresses.'),
|
||||||
'default' => false
|
'default' => false
|
||||||
]
|
],
|
||||||
|
'user.allow-user-deletion' => [
|
||||||
|
'name' => __('Allow user deletion'),
|
||||||
|
'type' => 'boolean',
|
||||||
|
'description' => __('This setting will allow the deletion of users by authorized users.'),
|
||||||
|
'default' => false
|
||||||
|
],
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
|
|
@ -145,6 +145,9 @@ echo $this->element('genericElements/IndexTable/index_table', [
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
'function' => function ($row, $options) use ($loggedUser, $validRoles) {
|
'function' => function ($row, $options) use ($loggedUser, $validRoles) {
|
||||||
|
if (empty(Configure::read('user.allow-user-deletion'))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if ($row['id'] == $loggedUser['id']) {
|
if ($row['id'] == $loggedUser['id']) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue