mirror of https://github.com/MISP/MISP
chg: [user] log last_api_access hourly if MISP.store_api_access_time is not set
parent
acb258cc52
commit
a5f5a4e113
|
@ -439,10 +439,7 @@ class AppController extends Controller
|
|||
);
|
||||
$this->Log->save($log);
|
||||
}
|
||||
$storeAPITime = Configure::read('MISP.store_api_access_time');
|
||||
if (!empty($storeAPITime) && $storeAPITime) {
|
||||
$this->User->updateAPIAccessTime($user);
|
||||
}
|
||||
$this->User->updateAPIAccessTime($user);
|
||||
$this->Session->renew();
|
||||
$this->Session->write(AuthComponent::$sessionKey, $user);
|
||||
$this->isApiAuthed = true;
|
||||
|
|
|
@ -1414,6 +1414,8 @@ class User extends AppModel
|
|||
|
||||
/**
|
||||
* Updates `last_api_access` time in database.
|
||||
* Always update when MISP.store_api_access_time is set.
|
||||
* Only update every hour when it isn't set
|
||||
*
|
||||
* @param array $user
|
||||
* @return array|bool
|
||||
|
@ -1424,8 +1426,11 @@ class User extends AppModel
|
|||
if (!isset($user['id'])) {
|
||||
throw new InvalidArgumentException("Invalid user object provided.");
|
||||
}
|
||||
$user['last_api_access'] = time();
|
||||
return $this->save($user, true, array('id', 'last_api_access'));
|
||||
$storeAPITime = Configure::read('MISP.store_api_access_time');
|
||||
if ((!empty($storeAPITime) && $storeAPITime) || $user['last_api_access'] < time() - 60*60) {
|
||||
$user['last_api_access'] = time();
|
||||
return $this->save($user, true, array('id', 'last_api_access'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -229,7 +229,6 @@
|
|||
'element' => 'datetime',
|
||||
'class' => 'short',
|
||||
'data_path' => 'User.last_api_access',
|
||||
'requirement' => !empty(Configure::read('MISP.store_api_access_time')),
|
||||
),
|
||||
array(
|
||||
'name' => (Configure::read('Plugin.CustomAuth_name') ? Configure::read('Plugin.CustomAuth_name') : __('External Auth')),
|
||||
|
|
Loading…
Reference in New Issue