Created
February 17, 2019 16:29
-
-
Save funador/8f7085ccb8ae251f33b7dcb767f3d0c4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = profile => { | |
const { provider } = profile | |
switch(provider) { | |
case 'twitter': | |
return { | |
name: profile.username, | |
photo: profile.photos[0].value.replace(/_normal/, '') | |
} | |
case 'google': | |
return { | |
name: profile.displayName, | |
photo: profile.photos[0].value.replace(/sz=50/gi, 'sz=250') | |
} | |
case 'facebook': | |
const { givenName = '', familyName = '' } = profile.name | |
return { | |
name: `${givenName} ${familyName}`, | |
photo: profile.photos[0].value | |
} | |
case 'github': | |
return { | |
name: profile.username, | |
photo: profile.photos[0].value | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment