rename directory config to profile config

This commit is contained in:
Girish Ramakrishnan
2022-01-13 14:34:02 -08:00
parent 09d3d258b6
commit d35f948157
5 changed files with 31 additions and 22 deletions

View File

@@ -58,8 +58,8 @@ exports = module.exports = {
getFooter,
setFooter,
getDirectoryConfig,
setDirectoryConfig,
getProfileConfig,
setProfileConfig,
getAppstoreListingConfig,
setAppstoreListingConfig,
@@ -105,7 +105,7 @@ exports = module.exports = {
SYSINFO_CONFIG_KEY: 'sysinfo_config',
APPSTORE_LISTING_CONFIG_KEY: 'appstore_listing_config',
SUPPORT_CONFIG_KEY: 'support_config',
DIRECTORY_CONFIG_KEY: 'directory_config',
PROFILE_CONFIG_KEY: 'profile_config',
GHOSTS_CONFIG_KEY: 'ghosts_config',
REVERSE_PROXY_CONFIG_KEY: 'reverseproxy_config',
@@ -204,7 +204,7 @@ const gDefaults = (function () {
result[exports.SYSINFO_CONFIG_KEY] = {
provider: 'generic'
};
result[exports.DIRECTORY_CONFIG_KEY] = {
result[exports.PROFILE_CONFIG_KEY] = {
lockUserProfiles: false,
mandatory2FA: false
};
@@ -608,19 +608,19 @@ async function setSysinfoConfig(sysinfoConfig) {
notifyChange(exports.SYSINFO_CONFIG_KEY, sysinfoConfig);
}
async function getDirectoryConfig() {
const value = await get(exports.DIRECTORY_CONFIG_KEY);
if (value === null) return gDefaults[exports.DIRECTORY_CONFIG_KEY];
async function getProfileConfig() {
const value = await get(exports.PROFILE_CONFIG_KEY);
if (value === null) return gDefaults[exports.PROFILE_CONFIG_KEY];
return JSON.parse(value);
}
async function setDirectoryConfig(directoryConfig) {
async function setProfileConfig(directoryConfig) {
assert.strictEqual(typeof directoryConfig, 'object');
if (isDemo()) throw new BoxError(BoxError.BAD_FIELD, 'Not allowed in demo mode');
const oldConfig = await getDirectoryConfig();
await set(exports.DIRECTORY_CONFIG_KEY, JSON.stringify(directoryConfig));
const oldConfig = await getProfileConfig();
await set(exports.PROFILE_CONFIG_KEY, JSON.stringify(directoryConfig));
if (directoryConfig.mandatory2FA && !oldConfig.mandatory2FA) {
debug('setDirectoryConfig: logging out non-2FA users to enforce 2FA');
@@ -631,7 +631,7 @@ async function setDirectoryConfig(directoryConfig) {
}
}
notifyChange(exports.DIRECTORY_CONFIG_KEY, directoryConfig);
notifyChange(exports.PROFILE_CONFIG_KEY, directoryConfig);
}
async function getReverseProxyConfig() {
@@ -758,7 +758,7 @@ async function list() {
result[exports.DEMO_KEY] = !!result[exports.DEMO_KEY];
// convert JSON objects
[exports.BACKUP_CONFIG_KEY, exports.DIRECTORY_CONFIG_KEY, exports.SERVICES_CONFIG_KEY, exports.EXTERNAL_LDAP_KEY, exports.REGISTRY_CONFIG_KEY, exports.SYSINFO_CONFIG_KEY, exports.REVERSE_PROXY_CONFIG_KEY ].forEach(function (key) {
[exports.BACKUP_CONFIG_KEY, exports.PROFILE_CONFIG_KEY, exports.SERVICES_CONFIG_KEY, exports.EXTERNAL_LDAP_KEY, exports.REGISTRY_CONFIG_KEY, exports.SYSINFO_CONFIG_KEY, exports.REVERSE_PROXY_CONFIG_KEY ].forEach(function (key) {
result[key] = typeof result[key] === 'object' ? result[key] : safe.JSON.parse(result[key]);
});