From 600f63bc7e3bd242afc79d6b631b05c95afe7c44 Mon Sep 17 00:00:00 2001 From: Dennis Eriksen Date: Mon, 29 Apr 2013 11:24:04 +0200 Subject: added new project page and cleaned up a bit --- router.js | 61 +++++++++++++++---------------------------------------------- 1 file changed, 15 insertions(+), 46 deletions(-) (limited to 'router.js') diff --git a/router.js b/router.js index bde3172..3ffc887 100644 --- a/router.js +++ b/router.js @@ -22,70 +22,39 @@ module.exports = function(app, passport, auth) { app.get('/faq', system.faq); - - app.get('/dashboard', system.dashboard); - - app.get('/login', users.login); + app.get('/signup', users.signup); - app.post('/login', users.signin); + app.post('/signup', users.create); - // GET /auth/facebook - // Use passport.authenticate() as route middleware to authenticate the - // request. The first step in Facebook authentication will involve - // redirecting the user to facebook.com. After authorization, Facebook will - // redirect the user back to this application at /auth/facebook/callback - app.get('/auth/facebook', passport.authenticate('facebook'), function(req, res){ - // The request will be redirected to Facebook for authentication, so this - // function will not be called. - }); + app.post('/test', users.signin); - // GET /auth/facebook/callback - // Use passport.authenticate() as route middleware to authenticate the - // request. If authentication fails, the user will be redirected back to the - // login page. Otherwise, the primary route function function will be called, - // which, in this example, will redirect the user to the home page. - app.get('/auth/facebook/callback', passport.authenticate('facebook', { failureRedirect: '/login' }), function(req, res) { + app.get('/auth/facebook', passport.authenticate('facebook', { failureRedirect: '/test' }), users.signin); + + app.get('/auth/facebook/callback', passport.authenticate('facebook', { failureRedirect: '/test' }), function(req, res) { console.log('/auth/facebook/callback --- ' + req.user.username); res.redirect('/dashboard'); }); - app.get('/auth/twitter', passport.authenticate('twitter', { failureRedirect: '/login' }), users.signin); - app.get('/auth/twitter/callback', passport.authenticate('twitter', { failureRedirect: '/login' }), users.authCallback); - - /* - * GET logout - * - * '/logout' - */ - app.get('/logout', users.logout); + app.get('/auth/twitter', passport.authenticate('twitter', { failureRedirect: '/test' }), users.signin); + app.get('/auth/twitter/callback', passport.authenticate('twitter', { failureRedirect: '/test' }), users.authCallback); + app.get('/logout', users.logout); - /* - * GET project page - * - * '/project' + /** + * REQUIRES LOGIN + * ============================================================ */ - app.get('/project', system.project); - - - - /* - * GET signup page - * - * '/signup' - */ - - app.get('/signup', users.signup); + app.get('/dashboard', system.dashboard); - /* POST */ - app.post('/signup', users.create); + app.get('/project', auth.requiresLogin, system.project); + app.get('/project/new', auth.requiresLogin, system.newproject); }; -- cgit v1.2.3