From 3833be8bc10b5d4d13be6dc73fe31d6bce8975dc Mon Sep 17 00:00:00 2001 From: Simon Fridlund Date: Tue, 30 Jun 2015 14:26:17 +0200 Subject: [PATCH] Use primary email for the email field MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The email provided by the user info in the response from /user is the publicly visible email, which a user can choose to not set. GitHub accounts always have a primary email, so let’s use that one instead. --- packages/github/github_server.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/github/github_server.js b/packages/github/github_server.js index fd3a513a06..aa1091c6c2 100644 --- a/packages/github/github_server.js +++ b/packages/github/github_server.js @@ -5,12 +5,13 @@ OAuth.registerService('github', 2, null, function(query) { var accessToken = getAccessToken(query); var identity = getIdentity(accessToken); var emails = getEmails(accessToken); + var primaryEmail = _.findWhere(emails, {primary: true}); return { serviceData: { id: identity.id, accessToken: OAuth.sealSecret(accessToken), - email: identity.email, + email: primaryEmail.email, username: identity.login, emails: emails },