mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-08-04 01:29:21 +00:00
[#1828] don't let users create party if they already belong to one
This commit is contained in:
parent
2b286ba889
commit
53db31d4fb
1 changed files with 14 additions and 6 deletions
|
|
@ -177,13 +177,21 @@ api.create = function(req, res, next) {
|
|||
});
|
||||
});
|
||||
}else{
|
||||
group.save(function(err, saved){
|
||||
async.waterfall([
|
||||
function(cb){
|
||||
Group.findOne({type:'party',members:{$in:[user._id]}},cb);
|
||||
},
|
||||
function(found, cb){
|
||||
if (found) return cb('Already in a party, try refreshing.');
|
||||
group.save(cb);
|
||||
},
|
||||
function(saved, count, cb){
|
||||
saved.populate('members', nameFields, cb);
|
||||
}
|
||||
], function(err, populated){
|
||||
if (err) return res.json(500,{err:err});
|
||||
saved.populate('members', nameFields, function(err, populated){
|
||||
if (err) return res.json(500,{err:err});
|
||||
return res.json(populated);
|
||||
});
|
||||
});
|
||||
return res.json(populated);
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue