mirror of https://github.com/MISP/MISP
commit
91a045c13f
|
@ -886,9 +886,9 @@ class UsersController extends AppController
|
|||
continue;
|
||||
}
|
||||
if ($field != 'confirm_password') {
|
||||
array_push($fieldsOldValues, $this->User->field($field));
|
||||
$fieldsOldValues[$field] = $this->User->field($field);
|
||||
} else {
|
||||
array_push($fieldsOldValues, $this->User->field('password'));
|
||||
$fieldsOldValues[$field] = $this->User->field('password');
|
||||
}
|
||||
}
|
||||
if (
|
||||
|
@ -929,31 +929,28 @@ class UsersController extends AppController
|
|||
}
|
||||
$cP++;
|
||||
}
|
||||
array_push($fieldsNewValues, $newValueStr);
|
||||
$fieldsNewValues[$field] = $newValueStr;
|
||||
} else {
|
||||
array_push($fieldsNewValues, $newValue);
|
||||
$fieldsNewValues[$field] = $newValue;
|
||||
}
|
||||
} else {
|
||||
array_push($fieldsNewValues, $this->data['User']['password']);
|
||||
$fieldsNewValues[$field] = $this->data['User']['password'];
|
||||
}
|
||||
}
|
||||
// compare
|
||||
$fieldsResultStr = '';
|
||||
$c = 0;
|
||||
$fieldsResult = array();
|
||||
foreach ($fields as $field) {
|
||||
if (isset($fieldsOldValues[$c]) && $fieldsOldValues[$c] != $fieldsNewValues[$c]) {
|
||||
if (isset($fieldsOldValues[$field]) && $fieldsOldValues[$field] != $fieldsNewValues[$field]) {
|
||||
if ($field != 'confirm_password' && $field != 'enable_password') {
|
||||
$fieldsResultStr = $fieldsResultStr . ', ' . $field . ' (' . $fieldsOldValues[$c] . ') => (' . $fieldsNewValues[$c] . ')';
|
||||
$fieldsResult[$field] = array($fieldsOldValues[$field], $fieldsNewValues[$field]);
|
||||
}
|
||||
}
|
||||
$c++;
|
||||
}
|
||||
$fieldsResultStr = substr($fieldsResultStr, 2);
|
||||
$user = $this->User->find('first', array(
|
||||
'recursive' => -1,
|
||||
'conditions' => array('User.id' => $this->User->id)
|
||||
));
|
||||
$this->User->extralog($this->Auth->user(), "edit", "user", $fieldsResultStr, $user);
|
||||
$this->User->extralog($this->Auth->user(), "edit", "user", $fieldsResult, $user);
|
||||
if ($this->_isRest()) {
|
||||
$user['User']['password'] = '******';
|
||||
return $this->RestResponse->viewData($user, $this->response->type());
|
||||
|
|
|
@ -189,6 +189,7 @@ class Log extends AppModel
|
|||
* @param int $modelId
|
||||
* @param string $title
|
||||
* @param string|array $change
|
||||
* @return array
|
||||
* @throws Exception
|
||||
*/
|
||||
public function createLogEntry($user, $action, $model, $modelId = 0, $title = '', $change = '')
|
||||
|
@ -227,6 +228,8 @@ class Log extends AppModel
|
|||
if (!$result) {
|
||||
throw new Exception("Cannot save log because of validation errors: " . json_encode($this->validationErrors));
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
// to combat a certain bug that causes the upgrade scripts to loop without being able to set the correct version
|
||||
|
|
|
@ -3,6 +3,9 @@ App::uses('AppModel', 'Model');
|
|||
App::uses('AuthComponent', 'Controller/Component');
|
||||
App::uses('RandomTool', 'Tools');
|
||||
|
||||
/**
|
||||
* @property Log $Log
|
||||
*/
|
||||
class User extends AppModel
|
||||
{
|
||||
public $displayField = 'email';
|
||||
|
@ -1419,20 +1422,12 @@ class User extends AppModel
|
|||
|
||||
// query
|
||||
$this->Log = ClassRegistry::init('Log');
|
||||
$this->Log->create();
|
||||
$this->Log->save(array(
|
||||
'org' => $user['Organisation']['name'],
|
||||
'model' => $model,
|
||||
'model_id' => $modelId,
|
||||
'email' => $user['email'],
|
||||
'action' => $action,
|
||||
'title' => $description,
|
||||
'change' => isset($fieldsResult) ? $fieldsResult : ''));
|
||||
$result = $this->Log->createLogEntry($user, $action, $model, $modelId, $description, $fieldsResult);
|
||||
|
||||
// write to syslogd as well
|
||||
App::import('Lib', 'SysLog.SysLog');
|
||||
$syslog = new SysLog();
|
||||
$syslog->write('notice', $description . ' -- ' . $action . (empty($fieldResult) ? '' : '-- ' . $fieldResult));
|
||||
$syslog->write('notice', "$description -- $action" . (empty($fieldResult) ? '' : ' -- ' . $result['Log']['change']));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue