fix: [user API] users/edit now avoids having to set confirm_password when setting a password via the API

nibbler
iglocska 2019-11-29 12:16:27 +01:00
parent b8e583f727
commit be4034d7a2
No known key found for this signature in database
GPG Key ID: BEA224F1FEF113AC
1 changed files with 6 additions and 0 deletions

View File

@ -171,11 +171,17 @@ class UsersController extends AppController
$fieldList = array('email', 'autoalert', 'gpgkey', 'certif_public', 'nids_sid', 'contactalert', 'disabled');
if (!empty($this->request->data['User']['password'])) {
$fieldList[] = 'password';
$fieldList[] = 'confirm_password';
}
foreach ($this->request->data['User'] as $k => $v) {
$currentUser['User'][$k] = $v;
}
// Save the data
if ($this->_isRest()) {
if (!empty($this->request->data['User']['password'])) {
$currentUser['User']['confirm_password'] = $this->request->data['User']['password'];
}
}
if ($this->User->save($currentUser, true, $fieldList)) {
if ($this->_isRest()) {
$user = $this->User->find('first', array(