This commit is contained in:
Michael Q Larson
2015-01-27 23:23:50 -08:00
3 changed files with 26 additions and 12 deletions

26
app.js
View File

@ -134,7 +134,6 @@ var trusted = [
'*.youtube.com',
];
debug(trusted);
app.use(helmet.contentSecurityPolicy({
defaultSrc: trusted,
scriptSrc: ['*.optimizely.com', '*.aspnetcdn.com'].concat(trusted),
@ -323,9 +322,17 @@ app.post('/completed-bonfire/', function (req, res) {
solution: isSolution
})
req.user.save();
pairedWith.save();
res.redirect('/bonfires');
req.user.save(function(err, user) {
pairedWith.save(function(err, paired) {
if (err) {
throw err;
}
if (user && paired) {
res.redirect('/bonfires');
}
})
});
}
})
} else {
@ -341,8 +348,15 @@ app.post('/completed-bonfire/', function (req, res) {
if (index > -1) {
req.user.uncompletedBonfires.splice(index,1)
}
req.user.save();
res.redirect('/bonfires');
req.user.save(function(err, user) {
if (err) {
throw err;
}
if (user) {
res.redirect('/bonfires');
}
});
}
});

View File

@ -95,7 +95,6 @@ exports.returnIndividualBonfire = function(req, res, next) {
next(err);
}
if (bonfire.length < 1) {
debug('Full Bonfire', bonfire);
req.flash('errors', {
msg: "404: We couldn't find a bonfire with that name. Please double check the name."
});

View File

@ -51,10 +51,6 @@ $(document).ready(function() {
url: '/completed-bonfire/'
});
//$.post( '/completed-bonfire', function( data ) {
// window.location = '/bonfires';
//});
}
}
@ -71,13 +67,18 @@ $(document).ready(function() {
window.location = '/challenges/' + (parseInt(l[l.length - 1]) + 1);
});
$('.next-bonfire-button').on('click', function() {
var bonfireSolution = myCodeMirror.getValue();
var thisBonfireHash = passedBonfireHash || null;
var didCompleteWith = $('#completed-with').val() || null;
completedBonfire(didCompleteWith, bonfireSolution, thisBonfireHash);
window.location = '/bonfires';
window.setTimeout(function() {
// TODO
window.location = '/bonfires';
}, 100);
});