redirects to correct challenge upon authentication
This commit is contained in:
@@ -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'
|
||||
|
Reference in New Issue
Block a user