2013-12-20 18:48:33 +00:00
|
|
|
/**
|
|
|
|
* GET /
|
2014-01-07 23:15:14 +00:00
|
|
|
* Home page.
|
2013-12-20 18:48:33 +00:00
|
|
|
*/
|
2014-01-13 09:34:54 +00:00
|
|
|
|
2013-11-20 02:31:31 +00:00
|
|
|
exports.index = function(req, res) {
|
2014-11-06 20:46:24 +00:00
|
|
|
if (req.user) {
|
2014-11-07 07:01:01 +00:00
|
|
|
if (req.user.challengesCompleted.length > 0) {
|
2014-11-27 06:00:28 +00:00
|
|
|
nextChallenge = Math.max.apply(Math, req.user.challengesHash) + 1;
|
2014-11-07 07:01:01 +00:00
|
|
|
res.redirect("challenges/" + nextChallenge);
|
|
|
|
} else {
|
|
|
|
res.redirect("challenges/0");
|
|
|
|
}
|
2014-11-06 20:46:24 +00:00
|
|
|
} else {
|
|
|
|
res.render('home', {
|
2014-11-23 21:08:46 +00:00
|
|
|
title: 'Learn to Code and Become a Software Engineer'
|
2014-11-06 20:46:24 +00:00
|
|
|
});
|
|
|
|
}
|
2014-10-20 19:37:48 +00:00
|
|
|
};
|