From d46ac080ddc7319a356722ff6164ab6e228c93aa Mon Sep 17 00:00:00 2001 From: Michael Q Larson Date: Fri, 9 Jan 2015 13:02:00 -0800 Subject: [PATCH] make twitter photo higher resolution on login. remove twitter redirect middleware --- app.js | 4 +--- config/passport.js | 21 +++------------------ 2 files changed, 4 insertions(+), 21 deletions(-) diff --git a/app.js b/app.js index 12269cf30d..699067b4fb 100644 --- a/app.js +++ b/app.js @@ -293,13 +293,11 @@ app.get('/auth/twitter', passport.authenticate('twitter')); app.get( '/auth/twitter/callback', passport.authenticate('twitter', { - successRedirect: '/auth/twitter/middle', + successRedirect: '/', failureRedirect: '/login' }) ); -app.get('/auth/twitter/middle', passportConf.hasEmail); - app.get( '/auth/linkedin', passport.authenticate('linkedin', { diff --git a/config/passport.js b/config/passport.js index 34aec6fd55..11b1c8115e 100644 --- a/config/passport.js +++ b/config/passport.js @@ -15,7 +15,6 @@ var _ = require('lodash'), module.exports = { isAuthenticated: isAuthenticated, isAuthorized: isAuthorized, - hasEmail: hasEmail }; passport.serializeUser(function(user, done) { @@ -59,7 +58,7 @@ passport.use(new TwitterStrategy(secrets.twitter, function(req, accessToken, tok user.tokens.push({ kind: 'twitter', accessToken: accessToken, tokenSecret: tokenSecret }); user.profile.name = user.profile.name || profile.displayName; user.profile.location = user.profile.location || profile._json.location; - user.profile.picture = user.profile.picture || profile._json.profile_image_url_https; + user.profile.picture = user.profile.picture || profile._json.profile_image_url_https.replace('_normal', ''); user.save(function(err) { req.flash('info', { msg: 'Twitter account has been linked.' }); done(err, user); @@ -75,13 +74,13 @@ passport.use(new TwitterStrategy(secrets.twitter, function(req, accessToken, tok // Twitter will not provide an email address. Period. // But a person’s twitter username is guaranteed to be unique // so we can "fake" a twitter email address as follows: - user.email = profile.username + "@please_add_your_email_here.com"; + user.email = ''; user.profile.username = profile.username; user.twitter = profile.id; user.tokens.push({ kind: 'twitter', accessToken: accessToken, tokenSecret: tokenSecret }); user.profile.name = profile.displayName; user.profile.location = profile._json.location; - user.profile.picture = profile._json.profile_image_url_https; + user.profile.picture = profile._json.profile_image_url_https.replace('_normal', ''); user.save(function(err) { done(err, user); }); @@ -477,20 +476,6 @@ function isAuthenticated(req, res, next) { res.redirect('/login'); } -function hasEmail(req, res) { - if (req.user) { - if (req.user.email) { - res.redirect('/'); - } else { - req.flash('info', { - msg: 'Please add your email address before starting our challenges.' - }); - res.redirect('/account'); - } - } -} - -// Authorization Required middleware. function isAuthorized(req, res, next) { var provider = req.path.split('/').slice(-1)[0];