Use primary email for the email field

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.
This commit is contained in:
Simon Fridlund
2015-06-30 14:26:17 +02:00
committed by Martijn Walraven
parent 7581cd398f
commit 3833be8bc1

View File

@@ -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
},