Skip to content

[BUG] Duplicate email signup shows generic error instead of helpful message #170

Description

@manjit1029

Description

When a user tries to sign up with an email that already exists, the app shows a generic "Form submit encountered an error, check console" alert instead of telling the user the email is already in use.

Steps to Reproduce

  1. Go to signup (contact form)
  2. Complete the form with a valid email
  3. Submit successfully
  4. Fill out the form again with the same email
  5. Submit — see generic error alert

Root Cause

Frontend (/pages/patient/contactForm.vue, lines 796-800):

catch (e) {
  console.log(e.statusMessage + ":");
  console.log(e.data);
  alert("Form submit encountered an error, check console");
}

The error is caught but only logged to console with a generic alert. There's even a // TODO make better than bandaid comment.

Backend (/server/api/contactForm/form.post.ts, line 75-77):
Uses handlePrismaError(e) from /server/utils/prismaErrors.ts which converts Prisma P2002 (unique constraint violation) into an HTTP error, but the error message doesn't specify which field caused the conflict.

Database: email String? @unique in Prisma schema enforces uniqueness at the DB level.

Fix

  1. In prismaErrors.ts: detect P2002 errors on the email field and return a specific message like "An account with this email already exists"
  2. In contactForm.vue: parse the error response and show field-specific error messages inline (red text under the email field) instead of a generic alert

Acceptance Criteria

  • When a duplicate email is submitted, user sees "An account with this email already exists" near the email field
  • No need to check browser console for error details
  • Generic alert is replaced with inline error messaging

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2: mediumImprovements, non-blocking bugsarea: formsContact form, request form, signupbugSomething isn't working

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions