Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix(signup): show multiple signup errors at once
  • Loading branch information
Theodore Li committed Apr 6, 2026
commit 4d553ca9a60c5f4f28db07484c732360e98ad574
26 changes: 13 additions & 13 deletions apps/sim/app/(auth)/reset-password/reset-password-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,38 +104,38 @@ export function SetNewPasswordForm({
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) {
setValidationMessage(errors.join(' '))
Comment thread
TheodoreSpeaks marked this conversation as resolved.
Outdated
return
}

Expand Down
9 changes: 3 additions & 6 deletions apps/sim/app/(auth)/signup/signup-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -229,15 +229,12 @@ function SignupFormContent({
errors.length > 0
) {
if (nameValidationErrors.length > 0) {
setNameErrors([nameValidationErrors[0]])
setShowNameValidationError(true)
}
if (emailValidationErrors.length > 0) {
setEmailErrors([emailValidationErrors[0]])
Comment thread
TheodoreSpeaks marked this conversation as resolved.
setShowEmailValidationError(true)
}
if (errors.length > 0) {
setPasswordErrors([errors[0]])
setShowValidationError(true)
}
setIsLoading(false)
Expand Down Expand Up @@ -400,7 +397,7 @@ function SignupFormContent({
/>
<div
className={cn(
'absolute right-0 left-0 z-10 grid transition-[grid-template-rows] duration-200 ease-out',
'grid transition-[grid-template-rows] duration-200 ease-out',
showNameValidationError && nameErrors.length > 0
? 'grid-rows-[1fr]'
: 'grid-rows-[0fr]'
Expand Down Expand Up @@ -438,7 +435,7 @@ function SignupFormContent({
/>
<div
className={cn(
'absolute right-0 left-0 z-10 grid transition-[grid-template-rows] duration-200 ease-out',
'grid transition-[grid-template-rows] duration-200 ease-out',
(showEmailValidationError && emailErrors.length > 0) ||
(emailError && !showEmailValidationError)
? 'grid-rows-[1fr]'
Expand Down Expand Up @@ -497,7 +494,7 @@ function SignupFormContent({
</div>
<div
className={cn(
'absolute right-0 left-0 z-10 grid transition-[grid-template-rows] duration-200 ease-out',
'grid transition-[grid-template-rows] duration-200 ease-out',
showValidationError && passwordErrors.length > 0
? 'grid-rows-[1fr]'
: 'grid-rows-[0fr]'
Expand Down
3 changes: 1 addition & 2 deletions apps/sim/app/api/auth/reset-password/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ export async function POST(request: NextRequest) {
const validationResult = resetPasswordSchema.safeParse(body)

if (!validationResult.success) {
const firstError = validationResult.error.errors[0]
const errorMessage = firstError?.message || 'Invalid request data'
const errorMessage = validationResult.error.errors.map((e) => e.message).join(' ')
Comment thread
TheodoreSpeaks marked this conversation as resolved.

logger.warn('Invalid password reset request data', {
errors: validationResult.error.format(),
Expand Down
Loading