re-factor all the audit source objects

This commit is contained in:
Girish Ramakrishnan
2019-03-25 15:07:06 -07:00
parent 39c0409d42
commit d752c68790
13 changed files with 59 additions and 85 deletions

View File

@@ -1,5 +1,15 @@
'use strict';
exports = module.exports = {
CRON: { userId: null, username: 'cron' }
CRON: { userId: null, username: 'cron' },
HEALTH_MONITOR: { userId: null, username: 'healthmonitor' },
SYSADMIN: { userId: null, username: 'sysadmin' },
TASK_MANAGER: { userId: null, username: 'taskmanager' },
fromRequest: fromRequest
};
function fromRequest(req) {
var ip = req.headers['x-forwarded-for'] || req.connection.remoteAddress || null;
return { ip: ip, username: req.user ? req.user.username : null, userId: req.user ? req.user.id : null };
}