Skip to content

Commit 99bfc99

Browse files
author
Theodore Li
committed
Catch user already exists, remove login form captcha
1 parent 5b0ed00 commit 99bfc99

File tree

2 files changed

+2
-37
lines changed

2 files changed

+2
-37
lines changed

apps/sim/app/(auth)/login/login-form.tsx

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
'use client'
22

3-
import { useEffect, useRef, useState } from 'react'
4-
import { Turnstile, type TurnstileInstance } from '@marsidev/react-turnstile'
3+
import { useRef, useState } from 'react'
54
import { createLogger } from '@sim/logger'
65
import { Eye, EyeOff, Loader2 } from 'lucide-react'
76
import Link from 'next/link'
@@ -87,12 +86,6 @@ export default function LoginPage({
8786
const [passwordErrors, setPasswordErrors] = useState<string[]>([])
8887
const [showValidationError, setShowValidationError] = useState(false)
8988
const [formError, setFormError] = useState<string | null>(null)
90-
const turnstileRef = useRef<TurnstileInstance>(null)
91-
const [turnstileSiteKey, setTurnstileSiteKey] = useState<string | undefined>()
92-
93-
useEffect(() => {
94-
setTurnstileSiteKey(getEnv('NEXT_PUBLIC_TURNSTILE_SITE_KEY'))
95-
}, [])
9689
const callbackUrlParam = searchParams?.get('callbackUrl')
9790
const isValidCallbackUrl = callbackUrlParam ? validateCallbackUrl(callbackUrlParam) : false
9891
const invalidCallbackRef = useRef(false)
@@ -170,20 +163,6 @@ export default function LoginPage({
170163
const safeCallbackUrl = callbackUrl
171164
let errorHandled = false
172165

173-
let token: string | undefined
174-
const widget = turnstileRef.current
175-
if (turnstileSiteKey && widget) {
176-
try {
177-
widget.reset()
178-
widget.execute()
179-
token = await widget.getResponsePromise()
180-
} catch {
181-
setFormError('Captcha verification failed. Please try again.')
182-
setIsLoading(false)
183-
return
184-
}
185-
}
186-
187166
setFormError(null)
188167
const result = await client.signIn.email(
189168
{
@@ -192,9 +171,6 @@ export default function LoginPage({
192171
callbackURL: safeCallbackUrl,
193172
},
194173
{
195-
headers: {
196-
...(token ? { 'x-captcha-response': token } : {}),
197-
},
198174
onError: (ctx: any) => {
199175
logger.error('Login error:', ctx.error)
200176

@@ -465,14 +441,6 @@ export default function LoginPage({
465441
</div>
466442
)}
467443

468-
{turnstileSiteKey && (
469-
<Turnstile
470-
ref={turnstileRef}
471-
siteKey={turnstileSiteKey}
472-
options={{ execution: 'execute', appearance: 'execute' }}
473-
/>
474-
)}
475-
476444
{formError && (
477445
<div className='text-red-400 text-xs'>
478446
<p>{formError}</p>

apps/sim/app/(auth)/signup/signup-form.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -280,10 +280,7 @@ function SignupFormContent({
280280
let errorCode = 'unknown'
281281
if (ctx.error.code?.includes('USER_ALREADY_EXISTS')) {
282282
errorCode = 'user_already_exists'
283-
errorMessage.push(
284-
'An account with this email already exists. Please sign in instead.'
285-
)
286-
setEmailError(errorMessage[0])
283+
setEmailError('An account with this email already exists. Please sign in instead.')
287284
} else if (
288285
ctx.error.code?.includes('BAD_REQUEST') ||
289286
ctx.error.message?.includes('Email and password sign up is not enabled')

0 commit comments

Comments
 (0)