From 08498e37ac271f610a4439c7d334538077f0fd03 Mon Sep 17 00:00:00 2001 From: Tyler Renelle Date: Sat, 2 Nov 2013 01:37:17 -0700 Subject: [PATCH] [#1718] don't 404 for group not found --- public/js/controllers/groupsCtrl.js | 2 +- src/controllers/groups.js | 13 ++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/public/js/controllers/groupsCtrl.js b/public/js/controllers/groupsCtrl.js index 893e7e37d0..53a39931b1 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 1318d67a8b..64a8486dce 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); + }); };