new: [user] Allow to disable user login change

pull/6532/head
Jakub Onderka 2020-10-31 11:02:24 +01:00
parent 8e76af6370
commit c8fcfaf5e2
2 changed files with 12 additions and 3 deletions

View File

@ -182,7 +182,10 @@ class UsersController extends AppController
}
if (!$abortPost) {
// What fields should be saved (allowed to be saved)
$fieldList = array('email', 'autoalert', 'gpgkey', 'certif_public', 'nids_sid', 'contactalert', 'disabled');
$fieldList = array('autoalert', 'gpgkey', 'certif_public', 'nids_sid', 'contactalert', 'disabled');
if ($this->__canChangeLogin()) {
$fieldList[] = 'email';
}
if ($this->__canChangePassword() && !empty($this->request->data['User']['password'])) {
$fieldList[] = 'password';
$fieldList[] = 'confirm_password';
@ -243,6 +246,7 @@ class UsersController extends AppController
$this->set('roles', $roles);
$this->set('id', $id);
$this->set('canChangePassword', $this->__canChangePassword());
$this->set('canChangeLogin', $this->__canChangeLogin());
}
public function change_pw()
@ -2735,4 +2739,9 @@ class UsersController extends AppController
{
return $this->ACL->canUserAccess($this->Auth->user(), 'users', 'change_pw');
}
private function __canChangeLogin()
{
return !Configure::read('MISP.disable_user_login_change');
}
}

View File

@ -3,7 +3,7 @@
<fieldset>
<legend><?php echo __('Edit My Profile'); ?></legend>
<?php
echo $this->Form->input('email');
echo $this->Form->input('email', ['disabled' => $canChangeLogin ? false : 'disabled']);
?>
<div class="input clear"></div>
<?php
@ -18,7 +18,7 @@
?>
<div class="input clear"></div>
<?php
echo $this->Form->input('nids_sid');
echo $this->Form->input('nids_sid', ['label' => __('NIDS SID')]);
?>
<div class="input clear"></div>
<?php