Skip to content

Commit 75cb5c3

Browse files
waleedlatif1claude
andcommitted
fix(auth): show captcha errors as form-level message, not password error
Captcha failures were misleadingly displayed under the password field. Added a dedicated formError state that renders above the submit button, making it clear the issue is with verification, not the password. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 5ae1d9e commit 75cb5c3

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ export default function LoginPage({
8787
const [password, setPassword] = useState('')
8888
const [passwordErrors, setPasswordErrors] = useState<string[]>([])
8989
const [showValidationError, setShowValidationError] = useState(false)
90+
const [formError, setFormError] = useState<string | null>(null)
9091
const turnstileRef = useRef<TurnstileInstance>(null)
9192
const turnstileSiteKey = useMemo(() => getEnv('NEXT_PUBLIC_TURNSTILE_SITE_KEY'), [])
9293
const buttonClass = useBrandedButtonClass()
@@ -176,13 +177,13 @@ export default function LoginPage({
176177
turnstileRef.current.execute()
177178
token = await turnstileRef.current.getResponsePromise(15_000)
178179
} catch {
179-
setPasswordErrors(['Captcha verification failed. Please try again.'])
180-
setShowValidationError(true)
180+
setFormError('Captcha verification failed. Please try again.')
181181
setIsLoading(false)
182182
return
183183
}
184184
}
185185

186+
setFormError(null)
186187
const result = await client.signIn.email(
187188
{
188189
email,
@@ -478,6 +479,12 @@ export default function LoginPage({
478479
/>
479480
)}
480481

482+
{formError && (
483+
<div className='text-red-400 text-xs'>
484+
<p>{formError}</p>
485+
</div>
486+
)}
487+
481488
<BrandedButton
482489
type='submit'
483490
disabled={isLoading}

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ function SignupFormContent({
9191
const [emailError, setEmailError] = useState('')
9292
const [emailErrors, setEmailErrors] = useState<string[]>([])
9393
const [showEmailValidationError, setShowEmailValidationError] = useState(false)
94+
const [formError, setFormError] = useState<string | null>(null)
9495
const turnstileRef = useRef<TurnstileInstance>(null)
9596
const turnstileSiteKey = useMemo(() => getEnv('NEXT_PUBLIC_TURNSTILE_SITE_KEY'), [])
9697
const buttonClass = useBrandedButtonClass()
@@ -256,13 +257,13 @@ function SignupFormContent({
256257
turnstileRef.current.execute()
257258
token = await turnstileRef.current.getResponsePromise(15_000)
258259
} catch {
259-
setPasswordErrors(['Captcha verification failed. Please try again.'])
260-
setShowValidationError(true)
260+
setFormError('Captcha verification failed. Please try again.')
261261
setIsLoading(false)
262262
return
263263
}
264264
}
265265

266+
setFormError(null)
266267
const response = await client.signUp.email(
267268
{
268269
email: emailValue,
@@ -484,6 +485,12 @@ function SignupFormContent({
484485
/>
485486
)}
486487

488+
{formError && (
489+
<div className='text-red-400 text-xs'>
490+
<p>{formError}</p>
491+
</div>
492+
)}
493+
487494
<BrandedButton
488495
type='submit'
489496
disabled={isLoading}

0 commit comments

Comments
 (0)