Skip to content

Commit 7739c51

Browse files
authored
Revert "login: handle redirect properly for Google OAuth (tldraw#7117)" (tldraw#7189)
This reverts commit 38d8ff5. was causing new signups to fail 😢 ### Change type - [ ] `bugfix` - [ ] `improvement` - [ ] `feature` - [ ] `api` - [x] `other` <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Replaces custom Google OAuth sign-in handler with Clerk Elements `Connection` inside `SignIn.Root` and removes the related redirect logic; deletes the obsolete TODO file. > > - **Auth UI (`apps/dotcom/client/src/tla/components/dialogs/TlaSignInDialog.tsx`)**: > - Replace custom Google OAuth handler and redirect logic with Clerk Elements: > - Add `@clerk/elements/common` and `@clerk/elements/sign-in` imports. > - Use `<SignIn.Root>` and `<Clerk.Connection name="google" asChild>` for the Google button with `<Clerk.Icon>`. > - Remove bespoke `handleGoogleSignIn` function and routing-based redirect URL construction. > - **Chore**: > - Delete `TlaSignInDialog.todo.md`. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 21db85a. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent b0e0801 commit 7739c51

2 files changed

Lines changed: 18 additions & 49 deletions

File tree

apps/dotcom/client/src/tla/components/dialogs/TlaSignInDialog.todo.md

Lines changed: 0 additions & 8 deletions
This file was deleted.

apps/dotcom/client/src/tla/components/dialogs/TlaSignInDialog.tsx

Lines changed: 18 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import { useClerk, useSignIn } from '@clerk/clerk-react'
2+
import * as Clerk from '@clerk/elements/common'
3+
import * as SignIn from '@clerk/elements/sign-in'
24
import { GetInviteInfoResponseBody } from '@tldraw/dotcom-shared'
35
import classNames from 'classnames'
46
import { ChangeEvent, ReactNode, useCallback, useEffect, useState, type FormEvent } from 'react'
@@ -9,7 +11,6 @@ import {
911
TldrawUiDialogHeader,
1012
TldrawUiDialogTitle,
1113
} from 'tldraw'
12-
import { routes } from '../../../routeDefs'
1314
import { defineMessages, F, useMsg } from '../../utils/i18n'
1415
import { TlaCtaButton } from '../TlaCtaButton/TlaCtaButton'
1516
import { TlaLogo } from '../TlaLogo/TlaLogo'
@@ -113,32 +114,6 @@ function TlaEnterEmailStep({
113114
error: null,
114115
})
115116

116-
const handleGoogleSignIn = useCallback(async () => {
117-
if (!isSignInLoaded || !signIn) return
118-
119-
try {
120-
const redirectUrl = inviteInfo
121-
? routes.tlaInvite(inviteInfo.inviteSecret, {
122-
asUrl: true,
123-
searchParams: { accept: 'true' },
124-
})
125-
: window.location.href
126-
127-
const result = await signIn.create({
128-
strategy: 'oauth_google',
129-
redirectUrl,
130-
})
131-
132-
// Redirect to Google's OAuth page
133-
const externalUrl = result.firstFactorVerification?.externalVerificationRedirectURL
134-
if (externalUrl) {
135-
window.location.href = externalUrl.toString()
136-
}
137-
} catch (err: any) {
138-
console.error('Google sign-in error:', err)
139-
}
140-
}, [signIn, isSignInLoaded, inviteInfo])
141-
142117
const handleEmailSubmit = useCallback(
143118
async (e: FormEvent) => {
144119
e.preventDefault()
@@ -226,20 +201,22 @@ function TlaEnterEmailStep({
226201
</>
227202
)}
228203
</div>
229-
<div className={styles.authGoogleButtonWrapper}>
230-
<TlaCtaButton
231-
data-testid="tla-google-sign-in-button"
232-
className={styles.authCtaButton}
233-
onClick={handleGoogleSignIn}
234-
>
235-
<img
236-
src="https://img.clerk.com/static/google.svg"
237-
alt="Google"
238-
referrerPolicy="strict-origin-when-cross-origin"
239-
/>
240-
<F defaultMessage="Sign in with Google" />
241-
</TlaCtaButton>
242-
</div>
204+
<SignIn.Root routing="virtual">
205+
<SignIn.Step name="start">
206+
<div className={styles.authGoogleButtonWrapper}>
207+
{/* @ts-ignore this is fine */}
208+
<Clerk.Connection name="google" asChild>
209+
<TlaCtaButton
210+
data-testid="tla-google-sign-in-button"
211+
className={styles.authCtaButton}
212+
>
213+
<Clerk.Icon icon="google" />
214+
<F defaultMessage="Sign in with Google" />
215+
</TlaCtaButton>
216+
</Clerk.Connection>
217+
</div>
218+
</SignIn.Step>
219+
</SignIn.Root>
243220

244221
<div className={styles.authDivider}>
245222
<span>

0 commit comments

Comments
 (0)