Move auth functions to central location
This commit is contained in:
42
server/utils/auth.js
Normal file
42
server/utils/auth.js
Normal file
@ -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;
|
||||
}
|
Reference in New Issue
Block a user