Skip to content
This repository has been archived by the owner on Aug 30, 2021. It is now read-only.

Commit

Permalink
Merge pull request #374 from igorauad/provider_names
Browse files Browse the repository at this point in the history
Infer first and last name from github and twitter response
  • Loading branch information
ilanbiala committed Jan 25, 2015
2 parents ecb1c68 + db067bb commit 2bba82e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
9 changes: 8 additions & 1 deletion config/strategies/github.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,15 @@ module.exports = function() {
providerData.refreshToken = refreshToken;

// Create the user OAuth profile
var displayName = profile.displayName.trim();
var iSpace = displayName.indexOf(' '); // index of the whitespace following the firstName
var firstName = iSpace !== -1 ? displayName.substring(0, iSpace) : displayName;
var lastName = iSpace !== -1 ? displayName.substring(iSpace + 1) : '';

var providerUserProfile = {
displayName: profile.displayName,
firstName: firstName,
lastName: lastName,
displayName: displayName,
email: profile.emails[0].value,
username: profile.username,
provider: 'github',
Expand Down
9 changes: 8 additions & 1 deletion config/strategies/twitter.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,15 @@ module.exports = function() {
providerData.tokenSecret = tokenSecret;

// Create the user OAuth profile
var displayName = profile.displayName.trim();
var iSpace = displayName.indexOf(' '); // index of the whitespace following the firstName
var firstName = iSpace !== -1 ? displayName.substring(0, iSpace) : displayName;
var lastName = iSpace !== -1 ? displayName.substring(iSpace + 1) : '';

var providerUserProfile = {
displayName: profile.displayName,
firstName: firstName,
lastName: lastName,
displayName: displayName,
username: profile.username,
provider: 'twitter',
providerIdentifierField: 'id_str',
Expand Down

0 comments on commit 2bba82e

Please sign in to comment.