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
+22
View File
@@ -15,6 +15,9 @@ exports = module.exports = {
getPasswordResetLink,
sendPasswordResetEmail,
setProfileConfig,
getProfileConfig,
getInviteLink,
sendInviteEmail,
@@ -263,3 +266,22 @@ async function sendInviteEmail(req, res, next) {
next(new HttpSuccess(202, {}));
}
async function getProfileConfig(req, res, next) {
const [error, directoryConfig] = await safe(users.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(users.setProfileConfig(req.body));
if (error) return next(BoxError.toHttpError(error));
next(new HttpSuccess(200, {}));
}