Skip to content

Commit

Permalink
allow to sign up with provider without email
Browse files Browse the repository at this point in the history
  • Loading branch information
elitan authored and plmercereau committed Mar 18, 2022
1 parent 666b411 commit 8bbc6a3
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/routes/signin/providers/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,6 @@ const manageProviderStrategy =
// check if user exists, using profile.id
const { id, email, displayName, avatarUrl } = transformProfile(profile);

// check email
if (!(await isValidEmail({ email }))) {
return done(new Error('email is not allowed'));
}

// check if user already exist with `id` (unique id from provider)
const userProvider = await gqlSdk
.authUserProviders({
Expand All @@ -108,6 +103,11 @@ const manageProviderStrategy =
}

if (email) {
// check email
if (!(await isValidEmail({ email }))) {
return done(new Error('email is not allowed'));
}

const user = await getUserByEmail(email);

if (user) {
Expand Down Expand Up @@ -137,7 +137,7 @@ const manageProviderStrategy =
const insertedUser = await insertUser({
email,
passwordHash: null,
emailVerified: true,
emailVerified: !!email,
defaultRole: defaultRole,
locale,
roles: {
Expand Down Expand Up @@ -221,7 +221,7 @@ export const initProvider = <T extends Strategy>(
avatarUrl?: string;
} => ({
id,
email: emails?.[0].value,
email: emails?.[0]?.value,
displayName: displayName,
avatarUrl: photos?.[0]?.value || getGravatarUrl(emails?.[0].value),
}),
Expand Down

0 comments on commit 8bbc6a3

Please sign in to comment.