async'ify the groups code

This commit is contained in:
Girish Ramakrishnan
2021-06-28 15:15:28 -07:00
parent 7009c142cb
commit 31498afe39
15 changed files with 392 additions and 1065 deletions

View File

@@ -381,16 +381,16 @@ function get(userId, callback) {
assert.strictEqual(typeof userId, 'string');
assert.strictEqual(typeof callback, 'function');
userdb.get(userId, function (error, result) {
userdb.get(userId, async function (error, result) {
if (error) return callback(error);
groups.getMembership(userId, function (error, groupIds) {
if (error) return callback(error);
let groupIds;
[error, groupIds] = await safe(groups.getMembership(userId));
if (error) return callback(error);
result.groupIds = groupIds;
result.groupIds = groupIds;
return callback(null, result);
});
return callback(null, result);
});
}
@@ -471,16 +471,11 @@ function update(user, data, auditSource, callback) {
});
}
function setMembership(user, groupIds, callback) {
async function setMembership(user, groupIds) {
assert.strictEqual(typeof user, 'object');
assert(Array.isArray(groupIds));
assert.strictEqual(typeof callback, 'function');
groups.setMembership(user.id, groupIds, function (error) {
if (error) return callback(error);
callback(null);
});
await groups.setMembership(user.id, groupIds);
}
function getAdmins(callback) {