From bea5dff5633904787ad75592eb9b0520333bd101 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Wed, 24 Jul 2013 12:52:16 -0400 Subject: [PATCH] fixed #31 - twitter profile picture now used as nodebb avatar in lieu of email address for gravatar --- public/css/topic.less | 4 ++++ public/templates/topic.tpl | 6 ++++-- src/login.js | 9 ++++++++- src/routes/authentication.js | 2 +- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/public/css/topic.less b/public/css/topic.less index 4cb218dd28..c0e1c51433 100644 --- a/public/css/topic.less +++ b/public/css/topic.less @@ -9,6 +9,10 @@ display: inline-block; text-align: center; font-size: 12px; + + .stats { + clear: both; + } } li { diff --git a/public/templates/topic.tpl b/public/templates/topic.tpl index ea5c412a42..e22b73972d 100644 --- a/public/templates/topic.tpl +++ b/public/templates/topic.tpl @@ -80,8 +80,10 @@ - {posts.user_rep} -
+
+ {posts.user_rep} +
+
diff --git a/src/login.js b/src/login.js index 8d5e64bfab..17dc94a10e 100644 --- a/src/login.js +++ b/src/login.js @@ -53,7 +53,7 @@ var user = require('./user.js'), } } - Login.loginViaTwitter = function(twid, handle, callback) { + Login.loginViaTwitter = function(twid, handle, photos, callback) { user.get_uid_by_twitter_id(twid, function(uid) { if (uid !== null) { // Existing User @@ -69,6 +69,13 @@ var user = require('./user.js'), // Save twitter-specific information to the user user.setUserField(uid, 'twid', twid); RDB.hset('twid:uid', twid, uid); + + // Save their photo, if present + if (photos && photos.length > 0) { + user.setUserField(uid, 'uploadedpicture', photos[0].value); + user.setUserField(uid, 'picture', photos[0].value); + } + callback(null, { uid: uid }); diff --git a/src/routes/authentication.js b/src/routes/authentication.js index bb76c717bf..ab9db73226 100644 --- a/src/routes/authentication.js +++ b/src/routes/authentication.js @@ -22,7 +22,7 @@ consumerSecret: global.config['social:twitter:secret'], callbackURL: nconf.get('url') + 'auth/twitter/callback' }, function(token, tokenSecret, profile, done) { - login_module.loginViaTwitter(profile.id, profile.username, function(err, user) { + login_module.loginViaTwitter(profile.id, profile.username, profile.photos, function(err, user) { if (err) { return done(err); } done(null, user); });