Add groups.getRoles

This commit is contained in:
Girish Ramakrishnan
2018-06-16 00:29:56 -07:00
parent e8d9597345
commit ca9cd2cf0f
3 changed files with 46 additions and 3 deletions

View File

@@ -19,6 +19,7 @@ exports = module.exports = {
isMember: isMember,
setRoles: setRoles,
getRoles: getRoles,
getGroups: getGroups,
setGroups: setGroups
@@ -267,3 +268,15 @@ function setRoles(groupId, roles, callback) {
callback(null);
});
}
function getRoles(userId, callback) {
assert.strictEqual(typeof userId, 'string');
assert.strictEqual(typeof callback, 'function');
groupdb.getRoles(userId, function (error, roles) {
if (error && error.reason === DatabaseError.NOT_FOUND) return callback(new GroupsError(GroupsError.NOT_FOUND));
if (error) return callback(new GroupsError(GroupsError.INTERNAL_ERROR, error));
callback(null, roles);
});
}