Amend app object where applicable to login event

This commit is contained in:
Johannes Zellner
2018-03-02 19:06:27 +01:00
parent 39d6ec96b7
commit 726202b040
2 changed files with 5 additions and 4 deletions
+4 -3
View File
@@ -26,9 +26,10 @@ var apps = require('../apps'),
util = require('util'),
_ = require('underscore');
function auditSource(req, appId) {
// appObject is optional here
function auditSource(req, appId, appObject) {
var ip = req.headers['x-forwarded-for'] || req.connection.remoteAddress || null;
return { authType: 'oauth', ip: ip, appId: appId };
return { authType: 'oauth', ip: ip, appId: appId, app: appObject };
}
// create OAuth 2.0 server
@@ -458,7 +459,7 @@ var authorization = [
if (error) return sendError(req, res, 'Internal error');
if (!access) return sendErrorPageOrRedirect(req, res, 'No access to this app.');
eventlog.add(eventlog.ACTION_USER_LOGIN, auditSource(req, appObject.id), { userId: req.oauth2.user.id, user: user.removePrivateFields(req.oauth2.user) });
eventlog.add(eventlog.ACTION_USER_LOGIN, auditSource(req, appObject.id, appObject), { userId: req.oauth2.user.id, user: user.removePrivateFields(req.oauth2.user) });
next();
});