Merge branch 'master' of https://github.com/FreeCodeCamp/freecodecamp
This commit is contained in:
22
app.js
22
app.js
@ -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,11 +322,19 @@ 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) {
|
||||||
|
if (err) {
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
if (user && paired) {
|
||||||
res.redirect('/bonfires');
|
res.redirect('/bonfires');
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
req.user.completedBonfires.push({
|
req.user.completedBonfires.push({
|
||||||
_id: bonfireHash,
|
_id: bonfireHash,
|
||||||
@ -341,9 +348,16 @@ 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) {
|
||||||
|
if (err) {
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
if (user) {
|
||||||
res.redirect('/bonfires');
|
res.redirect('/bonfires');
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -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."
|
||||||
});
|
});
|
||||||
|
@ -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.setTimeout(function() {
|
||||||
|
// TODO
|
||||||
window.location = '/bonfires';
|
window.location = '/bonfires';
|
||||||
|
}, 100);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user