Add API to set and transfer ownership
This commit is contained in:
@@ -8,7 +8,8 @@ exports = module.exports = {
|
||||
remove: remove,
|
||||
verifyPassword: verifyPassword,
|
||||
sendInvite: sendInvite,
|
||||
setGroups: setGroups
|
||||
setGroups: setGroups,
|
||||
transferOwnership: transferOwnership
|
||||
};
|
||||
|
||||
var assert = require('assert'),
|
||||
@@ -158,3 +159,17 @@ function setGroups(req, res, next) {
|
||||
next(new HttpSuccess(204));
|
||||
});
|
||||
}
|
||||
|
||||
function transferOwnership(req, res, next) {
|
||||
assert.strictEqual(typeof req.body, 'object');
|
||||
assert.strictEqual(typeof req.params.userId, 'string');
|
||||
|
||||
if (typeof req.body.ownerId !== 'string') return next(new HttpError(400, 'ownerId must be a string'));
|
||||
|
||||
users.transferOwnership(req.params.userId, req.body.ownerId, function (error) {
|
||||
if (error && error.reason === UsersError.NOT_FOUND) return next(new HttpError(404, 'No such user'));
|
||||
if (error) return next(new HttpError(500, error));
|
||||
|
||||
next(new HttpSuccess(200, {}));
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user