mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-07-17 09:22:19 +00:00
fix(groups): do not try to add members to a party when it does not exists
This commit is contained in:
parent
3c61b8dc4f
commit
d448ca3ac5
1 changed files with 7 additions and 1 deletions
|
|
@ -136,7 +136,13 @@ api.get = function(req, res, next) {
|
|||
populateQuery(gid, q);
|
||||
q.exec(function(err, group){
|
||||
if (err) return next(err);
|
||||
if (!group && gid!=='party') return res.json(404,{err: "Group not found or you don't have access."});
|
||||
if(!group){
|
||||
if(gid !== 'party') return res.json(404,{err: "Group not found or you don't have access."});
|
||||
|
||||
// Don't send a 404 when querying for a party even if it doesn't exist
|
||||
// so that users with no party don't get a 404 on every access to the site
|
||||
return res.json(group);
|
||||
}
|
||||
//Since we have a limit on how many members are populate to the group, we want to make sure the user is always in the group
|
||||
var userInGroup = _.find(group.members, function(member){ return member._id == user._id; });
|
||||
//If the group is private or the group is a party, then the user must be a member of the group based on access restrictions above
|
||||
|
|
|
|||
Loading…
Reference in a new issue