System keeps login history events forever by default -- override in config

This commit is contained in:
Bryan Ashby 2018-11-11 01:55:38 -07:00
parent e8e9df767f
commit 322274a115
2 changed files with 9 additions and 2 deletions

View File

@ -923,6 +923,12 @@ function getDefaultConfig() {
debug : {
assertsEnabled : false,
},
statLog : {
systemEvents : {
loginHistoryMax: -1 // forever
}
}
};
}

View File

@ -7,6 +7,7 @@ const clientConnections = require('./client_connections.js').clientConnections;
const StatLog = require('./stat_log.js');
const logger = require('./logger.js');
const Events = require('./events.js');
const Config = require('./config.js').get;
// deps
const async = require('async');
@ -86,12 +87,12 @@ function userLogin(client, username, password, cb) {
return StatLog.incrementUserStat(user, 'login_count', 1, callback);
},
function recordLoginHistory(callback) {
const LOGIN_HISTORY_MAX = 200; // history of up to last 200 callers
const loginHistoryMax = Config().statLog.systemEvents.loginHistoryMax;
const historyItem = JSON.stringify({
userId : user.userId,
sessionId : user.sessionId,
});
return StatLog.appendSystemLogEntry('user_login_history', historyItem, LOGIN_HISTORY_MAX, StatLog.KeepType.Max, callback);
return StatLog.appendSystemLogEntry('user_login_history', historyItem, loginHistoryMax, StatLog.KeepType.Max, callback);
}
],
err => {