fix(signup): signup auth (#15628)

* fix(models.user): Colocate all user methods

Moved user methods/extensions into one file. Tracked down `next method
called more than once` error and setting headers after their sent. Let
regular error handler handle api errors as well.

* feat(server.auth): Disable github account creation

We are no longer allowing account creation through github

* refactor(Auth): Move user identity link into models dir

* feat(Disable link account login): This removes the ability to use a linked account t

* feat(errorhandlers): Add opbeat, filter out handled error
This commit is contained in:
Berkeley Martinez
2017-07-13 11:39:07 -07:00
committed by mrugesh mohapatra
parent 7805d74ea7
commit 2fcd976700
17 changed files with 591 additions and 497 deletions

View File

@ -1,5 +1,7 @@
const githubRegex = (/github/i);
const providerHash = {
facebook: ({ id }) => id,
github: ({ username }) => username,
twitter: ({ username }) => username,
linkedin({ _json }) {
return _json && _json.publicProfileUrl || null;
@ -13,48 +15,49 @@ export function getUsernameFromProvider(provider, profile) {
null;
}
// using es6 argument destructing
export function setProfileFromGithub(
user,
{
profileUrl: githubURL,
username
},
{
id: githubId,
avatar_url: picture,
email: githubEmail,
created_at: joinedGithubOn,
blog: website,
location,
bio,
name
// createProfileAttributes(provider: String, profile: {}) => Object
export function createUserUpdatesFromProfile(provider, profile) {
if (githubRegex.test(provider)) {
return createProfileAttributesFromGithub(profile);
}
) {
return Object.assign(
user,
{
name,
email: user.email || githubEmail,
username: username.toLowerCase(),
return {
[getSocialProvider(provider)]: getUsernameFromProvider(
getSocialProvider(provider),
profile
)
};
}
// using es6 argument destructing
// createProfileAttributes(profile) => profileUpdate
function createProfileAttributesFromGithub(profile) {
const {
profileUrl: githubURL,
username,
_json: {
id: githubId,
avatar_url: picture,
email: githubEmail,
created_at: joinedGithubOn,
blog: website,
location,
bio,
joinedGithubOn,
website,
isGithubCool: true,
picture,
githubId,
githubURL,
githubEmail,
githubProfile: githubURL
}
);
}
export function getFirstImageFromProfile(profile) {
return profile && profile.photos && profile.photos[0] ?
profile.photos[0].value :
null;
name
} = {}
} = profile;
return {
name,
username: username.toLowerCase(),
location,
bio,
joinedGithubOn,
website,
isGithubCool: true,
picture,
githubId,
githubURL,
githubEmail,
githubProfile: githubURL
};
}
export function getSocialProvider(provider) {