split routes and model code into user-directory.js

This commit is contained in:
Girish Ramakrishnan
2024-06-12 10:27:59 +02:00
parent e1f87161a8
commit b4e7e394c3
10 changed files with 121 additions and 80 deletions
-22
View File
@@ -18,9 +18,6 @@ exports = module.exports = {
getPasswordResetLink,
sendPasswordResetEmail,
setProfileConfig,
getProfileConfig,
getInviteLink,
sendInviteEmail,
@@ -275,22 +272,3 @@ 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, {}));
}