From 370248d919e8f98cb7ffb8df4fd80b1a84911236 Mon Sep 17 00:00:00 2001 From: Simo Kinnunen Date: Tue, 18 Nov 2014 12:14:38 +0900 Subject: [PATCH] We might not get email data from some users if they didn't allow access to the address. Quick fix for now, should show an error page instead. --- lib/units/auth/oauth2/index.js | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/lib/units/auth/oauth2/index.js b/lib/units/auth/oauth2/index.js index b12f318c..6d8c672f 100644 --- a/lib/units/auth/oauth2/index.js +++ b/lib/units/auth/oauth2/index.js @@ -31,15 +31,20 @@ module.exports = function(options) { app.get( '/auth/oauth/callback' , function(req, res) { - res.redirect(urlutil.addParams(options.appUrl, { - jwt: jwtutil.encode({ - payload: { - email: req.user.email - , name: req.user.email.split('@', 1).join('') - } - , secret: options.secret - }) - })) + if (req.user.email) { + res.redirect(urlutil.addParams(options.appUrl, { + jwt: jwtutil.encode({ + payload: { + email: req.user.email + , name: req.user.email.split('@', 1).join('') + } + , secret: options.secret + }) + })) + } + else { + res.redirect('/auth/oauth/') + } } )