add groupIds to user object

This commit is contained in:
girish@cloudron.io
2016-02-08 20:38:50 -08:00
parent 14fab0992f
commit 0d4f113d7d
3 changed files with 32 additions and 1 deletions

View File

@@ -14,6 +14,8 @@ exports = module.exports = {
removeMember: removeMember,
isMember: isMember,
getGroups: getGroups,
ADMIN_GROUP_ID: 'gid:admin' // see db migration code
};
@@ -112,6 +114,18 @@ function getMembers(groupId, callback) {
});
}
function getGroups(userId, callback) {
assert.strictEqual(typeof userId, 'string');
assert.strictEqual(typeof callback, 'function');
groupdb.getGroups(userId, function (error, result) {
if (error && error.reason === DatabaseError.NOT_FOUND) return callback(new GroupError(GroupError.NOT_FOUND));
if (error) return callback(new GroupError(GroupError.INTERNAL_ERROR, error));
return callback(null, result);
});
}
function addMember(groupId, userId, callback) {
assert.strictEqual(typeof groupId, 'string');
assert.strictEqual(typeof userId, 'string');