Skip to content

Fix: enforce email validation on registration- Enforce email format v… - #205

Merged
Premshaw23 merged 1 commit into
Premshaw23:masterfrom
omnipotentchaos:feature/fix-email-validation
May 20, 2026
Merged

Fix: enforce email validation on registration- Enforce email format v…#205
Premshaw23 merged 1 commit into
Premshaw23:masterfrom
omnipotentchaos:feature/fix-email-validation

Conversation

@omnipotentchaos

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • 🐛 Bug fix
  • ✨ New feature
  • 📚 Documentation
  • 🎨 UI/UX improvement
  • ⚡ Performance improvement
  • 🔒 Security fix

Description

Enforces the pre-declared EMAIL_PATTERN in the register endpoint to ensure only valid email formats are processed and stored in the database. Previously, the validation pattern was declared but not used, allowing invalid emails to bypass verification.

Related Issues

Closes #167

Changes Made

  • Integrated EMAIL_PATTERN.test(email) check in app/api/register/route.js to reject invalid email formats.
  • Set up an early rejection with a 400 Bad Request and message "Invalid email address" if validation fails, preventing any file upload or database operations.
  • Created components/_tests_/registerRoute.test.js to add comprehensive Jest unit tests covering valid emails (like sub-addressed emails e.g. user+tag@domain.co.uk) and multiple invalid formats.
  • Verified in the test suite that validation occurs before database insertion.

Testing

How did you test these changes?

  • Tested locally
  • Tested on mobile
  • Tested different user roles
  • All roles tested

Screenshots (if applicable)

N/A (Backend API validation and test suite enhancements)

Checklist

  • No hardcoded secrets or credentials
  • .env.local is not committed
  • Code follows project style
  • Changes are documented
  • Build passes locally (npm run build)
  • No console errors/warnings

…erification using EMAIL_PATTERN in the register API route- Return 400 Bad Request early if validation fails, preventing database insertion- Add targeted unit tests for standard valid/invalid email formats- Closes Premshaw23#167
Copilot AI review requested due to automatic review settings May 20, 2026 18:35
@vercel

vercel Bot commented May 20, 2026

Copy link
Copy Markdown
Contributor

@omnipotentchaos is attempting to deploy a commit to the Prem Shaw's projects Team on Vercel.

A member of the Team first needs to authorize it.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR closes #167 by enforcing the existing EMAIL_PATTERN in the registration API route so invalid email formats are rejected early (before DB connection / blob upload), and adds Jest coverage to prevent regressions.

Changes:

  • Added an EMAIL_PATTERN.test(email) guard in POST /api/register that returns 400 with "Invalid email address".
  • Added Jest tests covering a successful registration with a valid email (including sub-addressing) and multiple invalid email formats, asserting that invalid input does not reach DB operations.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
app/api/register/route.js Adds early email-format validation using the pre-declared EMAIL_PATTERN to block invalid registrations before DB work.
components/tests/registerRoute.test.js Adds unit tests validating 201 success for valid emails and 400 rejection for invalid formats, including ensuring DB is not contacted on invalid input.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Premshaw23
Premshaw23 merged commit 95c1501 into Premshaw23:master May 20, 2026
7 of 9 checks passed
@Premshaw23

Copy link
Copy Markdown
Owner

Done 👍

@github-actions github-actions Bot added GSSoC'26 Part of GirlScript Summer of Code 2026 mentor:Ayushh-Sharmaa GSSoC: Mentor — @Ayushh-Sharmaa and removed mentor:Premshaw23 labels Jun 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc:approved GSSoC'26 Part of GirlScript Summer of Code 2026 level:intermediate mentor:Ayushh-Sharmaa GSSoC: Mentor — @Ayushh-Sharmaa type:feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SECURITY: Email validation pattern declared but not enforced

3 participants