Skip to content

Commit 5d8906d

Browse files
authored
fix: ensure only verified github emails (#6103)
1 parent 6070c97 commit 5d8906d

3 files changed

Lines changed: 11 additions & 2 deletions

File tree

packages/shared/src/components/auth/AuthOptionsInner.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import {
2323
} from '../../lib/betterAuth';
2424
import {
2525
getSocialAuthCallbackError,
26+
GITHUB_EMAIL_NOT_VERIFIED_ERROR,
2627
hasSocialAuthBootUser,
2728
refetchSocialAuthBoot,
2829
SOCIAL_AUTH_RETRY_MESSAGE,
@@ -393,6 +394,10 @@ function AuthOptionsInner({
393394
const callbackError = getSocialAuthCallbackError(e?.data);
394395
const callbackData =
395396
typeof e?.data === 'object' ? JSON.stringify(e.data) : undefined;
397+
const socialErrorMessage =
398+
callbackError === GITHUB_EMAIL_NOT_VERIFIED_ERROR
399+
? labels.auth.error.githubEmailNotVerified
400+
: SOCIAL_AUTH_RETRY_MESSAGE;
396401

397402
let boot;
398403
try {
@@ -414,7 +419,7 @@ function AuthOptionsInner({
414419
}),
415420
});
416421
if (!authFlowSucceededRef.current) {
417-
displayToast(SOCIAL_AUTH_RETRY_MESSAGE);
422+
displayToast(socialErrorMessage);
418423
}
419424
return;
420425
}
@@ -436,7 +441,7 @@ function AuthOptionsInner({
436441
}),
437442
});
438443
if (!authFlowSucceededRef.current) {
439-
displayToast(SOCIAL_AUTH_RETRY_MESSAGE);
444+
displayToast(socialErrorMessage);
440445
}
441446
return;
442447
}

packages/shared/src/components/auth/socialAuth.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import type { Boot } from '../../lib/boot';
33
export const SOCIAL_AUTH_RETRY_MESSAGE =
44
"We couldn't complete your social sign-in. Please try again.";
55

6+
export const GITHUB_EMAIL_NOT_VERIFIED_ERROR = 'github_email_not_verified';
7+
68
const SOCIAL_AUTH_BOOT_RETRY_DELAYS_MS = [0, 250, 750] as const;
79

810
type BootUser = Partial<Boot>['user'];

packages/shared/src/lib/labels.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ export const labels = {
2626
'❌ We ran into an unexpected error on our end. Please try again.',
2727
existingEmail:
2828
'That email is linked to a different sign-in method. Please try another provider.',
29+
githubEmailNotVerified:
30+
'Your GitHub email address is not verified. Please verify it on GitHub and try again.',
2931
},
3032
},
3133
referral: {

0 commit comments

Comments
 (0)