From f59399a3f61b30383ad80c2713dfedcf70a47319 Mon Sep 17 00:00:00 2001 From: Krishav Raj Singh Date: Sun, 20 Jul 2025 20:15:00 +0530 Subject: [PATCH] fix: fallback to google oauth if one tap logiin fails --- frontend/src/components/GoogleSignIn.tsx | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/frontend/src/components/GoogleSignIn.tsx b/frontend/src/components/GoogleSignIn.tsx index 79e83ee0..bd66036a 100644 --- a/frontend/src/components/GoogleSignIn.tsx +++ b/frontend/src/components/GoogleSignIn.tsx @@ -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());