From 7e0794c9a09ddfa3b10ed17a24cf76c3a4c06783 Mon Sep 17 00:00:00 2001 From: Theodore Li Date: Mon, 6 Apr 2026 16:15:23 -0700 Subject: [PATCH] fix(signup): show multiple signup errors at once (#3987) * fix(signup): show multiple signup errors at once * Fix reset password error formatting * Remove dead code * Fix unit tests --------- Co-authored-by: Theodore Li --- .../reset-password/reset-password-form.tsx | 46 +++++++++++-------- apps/sim/app/(auth)/signup/signup-form.tsx | 18 ++------ .../app/api/auth/reset-password/route.test.ts | 10 ++-- apps/sim/app/api/auth/reset-password/route.ts | 3 +- 4 files changed, 38 insertions(+), 39 deletions(-) diff --git a/apps/sim/app/(auth)/reset-password/reset-password-form.tsx b/apps/sim/app/(auth)/reset-password/reset-password-form.tsx index 0ff43b0561..08ec08b65f 100644 --- a/apps/sim/app/(auth)/reset-password/reset-password-form.tsx +++ b/apps/sim/app/(auth)/reset-password/reset-password-form.tsx @@ -97,49 +97,49 @@ export function SetNewPasswordForm({ }: SetNewPasswordFormProps) { const [password, setPassword] = useState('') const [confirmPassword, setConfirmPassword] = useState('') - const [validationMessage, setValidationMessage] = useState('') + const [validationMessages, setValidationMessages] = useState([]) const [showPassword, setShowPassword] = useState(false) const [showConfirmPassword, setShowConfirmPassword] = useState(false) const handleSubmit = async (e: React.FormEvent) => { e.preventDefault() + const errors: string[] = [] + if (password.length < 8) { - setValidationMessage('Password must be at least 8 characters long') - return + errors.push('Password must be at least 8 characters long') } if (password.length > 100) { - setValidationMessage('Password must not exceed 100 characters') - return + errors.push('Password must not exceed 100 characters') } if (!/[A-Z]/.test(password)) { - setValidationMessage('Password must contain at least one uppercase letter') - return + errors.push('Password must contain at least one uppercase letter') } if (!/[a-z]/.test(password)) { - setValidationMessage('Password must contain at least one lowercase letter') - return + errors.push('Password must contain at least one lowercase letter') } if (!/[0-9]/.test(password)) { - setValidationMessage('Password must contain at least one number') - return + errors.push('Password must contain at least one number') } if (!/[^A-Za-z0-9]/.test(password)) { - setValidationMessage('Password must contain at least one special character') - return + errors.push('Password must contain at least one special character') } if (password !== confirmPassword) { - setValidationMessage('Passwords do not match') + errors.push('Passwords do not match') + } + + if (errors.length > 0) { + setValidationMessages(errors) return } - setValidationMessage('') + setValidationMessages([]) onSubmit(password) } @@ -162,7 +162,10 @@ export function SetNewPasswordForm({ onChange={(e) => setPassword(e.target.value)} required placeholder='Enter new password' - className={cn('pr-10', validationMessage && 'border-red-500 focus:border-red-500')} + className={cn( + 'pr-10', + validationMessages.length > 0 && 'border-red-500 focus:border-red-500' + )} />