users: add route to disable 2fa

This commit is contained in:
Girish Ramakrishnan
2021-04-14 20:45:13 -07:00
parent 6d214cf0f2
commit f15714182b
3 changed files with 16 additions and 0 deletions

View File

@@ -15,6 +15,8 @@ exports = module.exports = {
clearAvatar,
makeOwner,
disableTwoFactorAuthentication,
load
};
@@ -156,6 +158,18 @@ function createInvite(req, res, next) {
});
}
function disableTwoFactorAuthentication(req, res, next) {
assert.strictEqual(typeof req.resource, 'object');
if (users.compareRoles(req.user.role, req.resource.role) < 0) return next(new HttpError(403, `role '${req.resource.role}' is required but user has only '${req.user.role}'`));
users.disableTwoFactorAuthentication(req.resource.id, function (error, result) {
if (error) return next(BoxError.toHttpError(error));
next(new HttpSuccess(200, result));
});
}
function sendInvite(req, res, next) {
assert.strictEqual(typeof req.resource, 'object');