Merge pull request #1022 from KrishavRajSingh/krishav/fix/google_oauth_login

fix: fallback to google oauth if one tap login fails
This commit is contained in:
Marko Kraemer 2025-07-21 18:43:07 +02:00 committed by GitHub
commit aa7ab3e425
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 11 additions and 3 deletions

View File

@ -59,12 +59,12 @@ export default function GoogleSignIn({ returnUrl }: GoogleSignInProps) {
const [isGoogleLoaded, setIsGoogleLoaded] = useState(false);
const { wasLastMethod, markAsUsed } = useAuthMethodTracking('google');
const supabase = createClient();
const handleGoogleSignIn = useCallback(
async (response: GoogleSignInResponse) => {
try {
setIsLoading(true);
const supabase = createClient();
console.log('Starting Google sign in process');
markAsUsed();
@ -111,14 +111,22 @@ export default function GoogleSignIn({ returnUrl }: GoogleSignInProps) {
setIsLoading(false);
toast.error('Google sign-in popup failed to load. Please try again.');
}, 5000);
window.google.accounts.id.prompt((notification) => {
window.google.accounts.id.prompt(async (notification) => {
clearTimeout(timeoutId);
if (notification.isNotDisplayed() || notification.isSkippedMoment()) {
console.log('Google sign-in was not displayed or skipped:',
notification.isNotDisplayed() ? notification.getNotDisplayedReason() : notification.getSkippedReason()
);
await supabase.auth.signInWithOAuth({
provider: 'google',
options: {
queryParams: {
prompt: 'select_account',
},
redirectTo: `${window.location.origin}/dashboard`,
},
});
setIsLoading(false);
} else if (notification.isDismissedMoment()) {
console.log('Google sign-in was dismissed:', notification.getDismissedReason());