userdirectory: add eventlog entry

This commit is contained in:
Girish Ramakrishnan
2024-06-12 10:46:23 +02:00
parent b4e7e394c3
commit b570f2f77d
6 changed files with 19 additions and 6 deletions

View File

@@ -9,6 +9,7 @@ const assert = require('assert'),
BoxError = require('./boxerror.js'),
constants = require('./constants.js'),
debug = require('debug')('box:user-directory'),
eventlog = require('./eventlog.js'),
oidc = require('./oidc.js'),
settings = require('./settings.js'),
tokens = require('./tokens.js'),
@@ -19,14 +20,17 @@ async function getProfileConfig() {
return value || { lockUserProfiles: false, mandatory2FA: false };
}
async function setProfileConfig(profileConfig) {
async function setProfileConfig(profileConfig, auditSource) {
assert.strictEqual(typeof profileConfig, 'object');
assert(auditSource && typeof auditSource === 'object');
if (constants.DEMO) throw new BoxError(BoxError.BAD_STATE, 'Not allowed in demo mode');
const oldConfig = await getProfileConfig();
await settings.setJson(settings.PROFILE_CONFIG_KEY, profileConfig);
await eventlog.add(eventlog.ACTION_USER_DIRECTORY_PROFILE_CONFIG_UPDATE, auditSource, { oldConfig, config: profileConfig });
if (profileConfig.mandatory2FA && !oldConfig.mandatory2FA) {
debug('setProfileConfig: logging out non-2FA users to enforce 2FA');