Add challenge to user.challenges on creation. Fixes #2310

This commit is contained in:
Cole Gleason
2014-01-08 16:41:16 -06:00
parent 76ed4a956c
commit 76ad3bbe78
+5
View File
@@ -82,6 +82,11 @@ ChallengeSchema.methods.syncToUser = function(user, cb) {
var self = this;
self.shortName = self.shortName || self.name;
// Add challenge to user.challenges
if (!_.contains(user.challenges, self._id)) {
user.challenges.push(self._id);
}
// Sync tags
var tags = user.tags || [];
var i = _.findIndex(tags, {id: self._id})