diff --git a/public/js/controllers/groupsCtrl.js b/public/js/controllers/groupsCtrl.js index 5747e20be0..080375c7ed 100644 --- a/public/js/controllers/groupsCtrl.js +++ b/public/js/controllers/groupsCtrl.js @@ -230,4 +230,4 @@ habitrpg.controller("GroupsCtrl", ['$scope', '$rootScope', 'Groups', '$http', 'A User.log({op:'set',data:{'flags.rest':User.user.flags.rest}}); } } - ]) \ No newline at end of file + ]) diff --git a/src/controllers/groups.js b/src/controllers/groups.js index 6bc453b95d..1b14828111 100644 --- a/src/controllers/groups.js +++ b/src/controllers/groups.js @@ -124,13 +124,12 @@ api.get = function(req, res) { var q = (gid == 'party') ? Group.findOne({type: 'party', members: {'$in': [user._id]}}) : Group.findById(gid); populateQuery(gid, q); q.exec(function(err, group){ - if (!group) return res.json(404, {err: 'Group not found'}); - if ( (group.type == 'guild' && group.privacy == 'private') || (group.type == 'party' && gid != 'party')) { - if(!_.find(group.members, {_id: user._id})) - return res.json(401, {err: "You don't have access to this group"}); - } - res.json(group); - }); + if ( group && (group.type == 'guild' && group.privacy == 'private') || (group.type == 'party')) { + if(!_.find(group.members, {_id: user._id})) + return res.json(401, {err: "You don't have access to this group"}); + } + res.json(group); + }); };