Add set ghost route
This commit is contained in:
@@ -10,6 +10,7 @@ exports = module.exports = {
|
||||
verifyPassword,
|
||||
sendInvite,
|
||||
setGroups,
|
||||
setGhost,
|
||||
makeOwner,
|
||||
|
||||
disableTwoFactorAuthentication,
|
||||
@@ -174,6 +175,19 @@ async function setGroups(req, res, next) {
|
||||
next(new HttpSuccess(204));
|
||||
}
|
||||
|
||||
async function setGhost(req, res, next) {
|
||||
assert.strictEqual(typeof req.body, 'object');
|
||||
assert.strictEqual(typeof req.resource, 'object');
|
||||
|
||||
if (typeof req.body.password !== 'string' || !req.body.password) return next(new HttpError(400, 'password must be non-empty string'));
|
||||
if ('expiresAt' in req.body && typeof req.body.password !== 'number') return next(new HttpError(400, 'expiresAt must be a number'));
|
||||
|
||||
const [error] = await safe(users.setGhost(req.resource, req.body.password, req.body.expiresAt || null));
|
||||
if (error) return next(BoxError.toHttpError(error));
|
||||
|
||||
next(new HttpSuccess(204));
|
||||
}
|
||||
|
||||
async function setPassword(req, res, next) {
|
||||
assert.strictEqual(typeof req.body, 'object');
|
||||
assert.strictEqual(typeof req.resource, 'object');
|
||||
|
||||
Reference in New Issue
Block a user