From 0d4742fdbb93629c063db380e7ae55b1c23b6863 Mon Sep 17 00:00:00 2001 From: Anthony Metzidis Date: Fri, 20 Oct 2017 12:48:04 -0700 Subject: [PATCH] simplify redirect to google --- config.js | 2 +- server.js | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/config.js b/config.js index e6c405c..289fc04 100644 --- a/config.js +++ b/config.js @@ -1,5 +1,5 @@ { - "scheme" : "https", + "scheme" : "http", "port": 7777, "keyLength": 10, diff --git a/server.js b/server.js index ca58076..2fb2f79 100644 --- a/server.js +++ b/server.js @@ -171,10 +171,6 @@ router.post('/documents', ensureAuthenticatedAPI, function(request, response, ne }); router.get('/documents/:id', ensureAuthenticatedAPI, function(request, response, next) { - if(!request.isAuthenticated()){ - response.sendStatus(401); - return response.end(); - } var skipExpire = !!config.documents[request.params.id]; return documentHandler.handleGet( request.params.id, @@ -188,7 +184,9 @@ router.get('/users/me', ensureAuthenticatedAPI, function(req, res, next) { function ensureAuthenticatedWeb(req, res, next) { if (req.isAuthenticated()) { return next(); } - res.redirect('/login'); + // res.redirect('/login' + '?next=' + encodeURIComponent(req.path)); + // if not authenticated, authenticate with google + passport.authenticate('google', { scope: ['profile'] })(req,res,next) } function ensureAuthenticatedAPI(req, res, next) { if (req.isAuthenticated()) { return next(); }