forked from freeCodeCamp/freeCodeCamp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move auth functions to central location
- Loading branch information
Berkeley Martinez
authored and
Berkeley Martinez
committed
Aug 13, 2015
1 parent
49e9d07
commit a4e220e
Showing
3 changed files
with
49 additions
and
80 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import assign from 'object.assign'; | ||
|
||
// using es6 argument destructing | ||
export function setProfileFromGithub( | ||
user, | ||
{ | ||
profileUrl: githubURL, | ||
username | ||
}, | ||
{ | ||
id: githubId, | ||
'avatar_url': picture, | ||
email: githubEmail, | ||
'created_at': joinedGithubOn, | ||
blog: website, | ||
location, | ||
name | ||
} | ||
) { | ||
return assign( | ||
user, | ||
{ isGithubCool: true, isMigrationGrandfathered: false }, | ||
{ | ||
name, | ||
username: username.toLowerCase(), | ||
location, | ||
joinedGithubOn, | ||
website, | ||
picture, | ||
githubId, | ||
githubURL, | ||
githubEmail, | ||
githubProfile: githubURL | ||
} | ||
); | ||
} | ||
|
||
export function getFirstImageFromProfile(profile) { | ||
return profile && profile.photos && profile.photos[0] ? | ||
profile.photos[0].value : | ||
null; | ||
} |