settings: make user_directory setting route

This commit is contained in:
Girish Ramakrishnan
2023-08-03 08:11:42 +05:30
parent d475df8d63
commit d12e6ee2b3
10 changed files with 85 additions and 109 deletions
-23
View File
@@ -152,25 +152,6 @@ async function setRegistryConfig(req, res, next) {
next(new HttpSuccess(200));
}
async function getProfileConfig(req, res, next) {
const [error, directoryConfig] = await safe(settings.getProfileConfig());
if (error) return next(BoxError.toHttpError(error));
next(new HttpSuccess(200, directoryConfig));
}
async function setProfileConfig(req, res, next) {
assert.strictEqual(typeof req.body, 'object');
if (typeof req.body.lockUserProfiles !== 'boolean') return next(new HttpError(400, 'lockUserProfiles is required'));
if (typeof req.body.mandatory2FA !== 'boolean') return next(new HttpError(400, 'mandatory2FA is required'));
const [error] = await safe(settings.setProfileConfig(req.body));
if (error) return next(BoxError.toHttpError(error));
next(new HttpSuccess(200, {}));
}
async function getLanguage(req, res, next) {
const [error, language] = await safe(settings.getLanguage());
if (error) return next(BoxError.toHttpError(error));
@@ -201,8 +182,6 @@ function get(req, res, next) {
case settings.AUTOUPDATE_PATTERN_KEY: return getAutoupdatePattern(req, res, next);
case settings.TIME_ZONE_KEY: return getTimeZone(req, res, next);
case settings.PROFILE_CONFIG_KEY: return getProfileConfig(req, res, next);
default: return next(new HttpError(404, 'No such setting'));
}
}
@@ -218,8 +197,6 @@ function set(req, res, next) {
case settings.AUTOUPDATE_PATTERN_KEY: return setAutoupdatePattern(req, res, next);
case settings.TIME_ZONE_KEY: return setTimeZone(req, res, next);
case settings.PROFILE_CONFIG_KEY: return setProfileConfig(req, res, next);
default: return next(new HttpError(404, 'No such setting'));
}
}