Merge branch 'develop' of https://github.com/HabitRPG/habitrpg into develop

This commit is contained in:
Matteo Pagliazzi
2013-11-02 09:54:44 +01:00
2 changed files with 7 additions and 8 deletions

View File

@@ -230,4 +230,4 @@ habitrpg.controller("GroupsCtrl", ['$scope', '$rootScope', 'Groups', '$http', 'A
User.log({op:'set',data:{'flags.rest':User.user.flags.rest}}); User.log({op:'set',data:{'flags.rest':User.user.flags.rest}});
} }
} }
]) ])

View File

@@ -124,13 +124,12 @@ api.get = function(req, res) {
var q = (gid == 'party') ? Group.findOne({type: 'party', members: {'$in': [user._id]}}) : Group.findById(gid); var q = (gid == 'party') ? Group.findOne({type: 'party', members: {'$in': [user._id]}}) : Group.findById(gid);
populateQuery(gid, q); populateQuery(gid, q);
q.exec(function(err, group){ q.exec(function(err, group){
if (!group) return res.json(404, {err: 'Group not found'}); if ( group && (group.type == 'guild' && group.privacy == 'private') || (group.type == 'party')) {
if ( (group.type == 'guild' && group.privacy == 'private') || (group.type == 'party' && gid != 'party')) { if(!_.find(group.members, {_id: user._id}))
if(!_.find(group.members, {_id: user._id})) return res.json(401, {err: "You don't have access to this group"});
return res.json(401, {err: "You don't have access to this group"}); }
} res.json(group);
res.json(group); });
});
}; };