redirects to correct challenge upon authentication

This commit is contained in:
Michael Q Larson
2014-11-06 23:01:01 -08:00
parent e36a98cf2a
commit ca0c71b77f
3 changed files with 13 additions and 8 deletions

View File

@@ -5,7 +5,12 @@
exports.index = function(req, res) {
if (req.user) {
res.redirect('challenges/a-one-minute-introduction-to-free-code-camp');
if (req.user.challengesCompleted.length > 0) {
nextChallenge = Math.max.apply(Math, req.user.challengesCompleted) + 1;
res.redirect("challenges/" + nextChallenge);
} else {
res.redirect("challenges/0");
}
} else {
res.render('home', {
title: 'Home'