Skip to content

fix : added email format and password length validation to auth route - #19

Open
tmdeveloper007 wants to merge 1 commit into
syedahmedkhaderi:mainfrom
tmdeveloper007:#auth-input-validation
Open

fix : added email format and password length validation to auth route#19
tmdeveloper007 wants to merge 1 commit into
syedahmedkhaderi:mainfrom
tmdeveloper007:#auth-input-validation

Conversation

@tmdeveloper007

Copy link
Copy Markdown

Summary of What Has Been Done:
Added email format validation using a regex check, minimum password length validation (8 characters) for signup, action parameter validation (must be 'signup' or 'login'), graceful handling of invalid JSON body, and trimming of the display_name field.

Changes Made:

  • app/api/auth/route.js: added EMAIL_REGEX constant and format validation
  • app/api/auth/route.js: added MIN_PASSWORD_LENGTH constant (8) and length check for signup
  • app/api/auth/route.js: added explicit action validation to reject unknown values
  • app/api/auth/route.js: added try/catch around req.json() for 400 on invalid JSON

Impact it Made:

  • Prevents invalid email formats from reaching Supabase signup
  • Enforces minimum password strength for new accounts
  • Rejects unknown action values early before captcha verification
  • Returns appropriate 400 status codes for bad input

Add email format validation using a regex check before attempting
signup/login.
Add minimum password length check (8 chars) for signup action.
Validate action parameter is exactly 'signup' or 'login'.
Handle invalid JSON body gracefully (400 response).
Trim the display_name field in signup options.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant