diff --git a/app.js b/app.js index 1a652cfc35..8a2d3f7e86 100644 --- a/app.js +++ b/app.js @@ -175,27 +175,27 @@ app.post('/completed_challenge', function(req, res){ */ app.get('/auth/instagram', passport.authenticate('instagram')); -app.get('/auth/instagram/callback', passport.authenticate('instagram', { successRedirect: '/challenges/a-one-minute-introduction-to-free-code-camp',failureRedirect: '/login' }), function(req, res) { +app.get('/auth/instagram/callback', passport.authenticate('instagram', { successRedirect: '/',failureRedirect: '/login' }), function(req, res) { res.redirect(req.session.returnTo || '/'); }); app.get('/auth/facebook', passport.authenticate('facebook', { scope: ['email', 'user_location'] })); -app.get('/auth/facebook/callback', passport.authenticate('facebook', { successRedirect: '/challenges/a-one-minute-introduction-to-free-code-camp',failureRedirect: '/login' }), function(req, res) { +app.get('/auth/facebook/callback', passport.authenticate('facebook', { successRedirect: '/',failureRedirect: '/login' }), function(req, res) { res.redirect(req.session.returnTo || '/'); }); app.get('/auth/github', passport.authenticate('github')); -app.get('/auth/github/callback', passport.authenticate('github', { successRedirect: '/challenges/a-one-minute-introduction-to-free-code-camp',failureRedirect: '/login' }), function(req, res) { +app.get('/auth/github/callback', passport.authenticate('github', { successRedirect: '/',failureRedirect: '/login' }), function(req, res) { res.redirect(req.session.returnTo || '/'); }); app.get('/auth/google', passport.authenticate('google', { scope: 'profile email' })); -app.get('/auth/google/callback', passport.authenticate('google', { successRedirect: '/challenges/a-one-minute-introduction-to-free-code-camp',failureRedirect: '/login' }), function(req, res) { +app.get('/auth/google/callback', passport.authenticate('google', { successRedirect: '/',failureRedirect: '/login' }), function(req, res) { res.redirect(req.session.returnTo || '/'); }); app.get('/auth/twitter', passport.authenticate('twitter')); -app.get('/auth/twitter/callback', passport.authenticate('twitter', { successRedirect: '/challenges/a-one-minute-introduction-to-free-code-camp',failureRedirect: '/login' }), function(req, res) { +app.get('/auth/twitter/callback', passport.authenticate('twitter', { successRedirect: '/',failureRedirect: '/login' }), function(req, res) { res.redirect(req.session.returnTo || '/'); }); app.get('/auth/linkedin', passport.authenticate('linkedin', { state: 'SOME STATE' })); -app.get('/auth/linkedin/callback', passport.authenticate('linkedin', { successRedirect: '/challenges/a-one-minute-introduction-to-free-code-camp',failureRedirect: '/login' }), function(req, res) { +app.get('/auth/linkedin/callback', passport.authenticate('linkedin', { successRedirect: '/',failureRedirect: '/login' }), function(req, res) { res.redirect(req.session.returnTo || '/'); }); diff --git a/controllers/home.js b/controllers/home.js index cb0c0dbf53..0329833889 100644 --- a/controllers/home.js +++ b/controllers/home.js @@ -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' diff --git a/models/User.js b/models/User.js index c8c7e60018..d4a265ccc7 100644 --- a/models/User.js +++ b/models/User.js @@ -13,7 +13,7 @@ var userSchema = new mongoose.Schema({ google: String, instagram: String, tokens: Array, - challengesCompleted: Array, + challengesCompleted: { type: Array, default: [] }, profile: { name: { type: String, default: '' },