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

View File

@ -95,7 +95,6 @@ exports.returnIndividualBonfire = function(req, res, next) {
next(err); next(err);
} }
if (bonfire.length < 1) { if (bonfire.length < 1) {
debug('Full Bonfire', bonfire);
req.flash('errors', { req.flash('errors', {
msg: "404: We couldn't find a bonfire with that name. Please double check the name." 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/' 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); window.location = '/challenges/' + (parseInt(l[l.length - 1]) + 1);
}); });
$('.next-bonfire-button').on('click', function() { $('.next-bonfire-button').on('click', function() {
var bonfireSolution = myCodeMirror.getValue(); var bonfireSolution = myCodeMirror.getValue();
var thisBonfireHash = passedBonfireHash || null; var thisBonfireHash = passedBonfireHash || null;
var didCompleteWith = $('#completed-with').val() || null; var didCompleteWith = $('#completed-with').val() || null;
completedBonfire(didCompleteWith, bonfireSolution, thisBonfireHash); completedBonfire(didCompleteWith, bonfireSolution, thisBonfireHash);
window.location = '/bonfires';
window.setTimeout(function() {
// TODO
window.location = '/bonfires';
}, 100);
}); });