granting and rescinding ownership, #2588

This commit is contained in:
Julian Lam
2015-01-08 15:13:05 -05:00
parent a907fa2187
commit d747ce5760
4 changed files with 91 additions and 26 deletions

View File

@@ -20,4 +20,32 @@ SocketGroups.leave = function(socket, data, callback) {
groups.leave(data.groupName, socket.uid, callback);
};
SocketGroups.grant = function(socket, data, callback) {
if (!data) {
return callback(new Error('[[error:invalid-data]]'));
}
groups.ownership.isOwner(socket.uid, data.groupName, function(err, isOwner) {
if (!isOwner) {
return callback(new Error('[[error:no-privileges]]'));
}
groups.ownership.grant(data.toUid, data.groupName, callback);
});
};
SocketGroups.rescind = function(socket, data, callback) {
if (!data) {
return callback(new Error('[[error:invalid-data]]'));
}
groups.ownership.isOwner(socket.uid, data.groupName, function(err, isOwner) {
if (!isOwner) {
return callback(new Error('[[error:no-privileges]]'));
}
groups.ownership.rescind(data.toUid, data.groupName, callback);
});
};
module.exports = SocketGroups;