Skip to content

Dev#46

Merged
Benji918 merged 5 commits into
stagingfrom
dev
May 21, 2026
Merged

Dev#46
Benji918 merged 5 commits into
stagingfrom
dev

Conversation

@DanielPopoola
Copy link
Copy Markdown
Collaborator

Description

This PR fixes backend email normalization inconsistencies by enforcing canonical email handling (trim + lowercase) at both the schema and service layers in authentication flows.

It prevents duplicate-account edge cases caused by casing or whitespace differences, ensures consistent login and existence checks, and keeps verification-related email inputs aligned with the same normalization behavior.


Type of Change

  • feat — New feature
  • fix — Bug fix
  • refactor — Code refactoring (no functional change)
  • docs — Documentation update
  • test — Adding or updating tests
  • chore — Maintenance (dependencies, CI, tooling)

Related Issue

Closes #


Changes Made

Added/updated schema-level email normalization

Updated auth request schemas to consistently:

  • trim surrounding whitespace
  • convert emails to lowercase

Applied to:

  • SignupRequest
  • LoginRequest
  • ForgotPasswordRequest
  • verification resend schema

Added service-layer normalization in AuthService

Normalization is now enforced even outside schema-bound request paths.

Updated:

  • check_email_exists
  • create_user
  • login

This ensures all auth flows use canonical email handling regardless of entry point.


Added and extended tests

Added coverage to verify:

  • schema normalization behavior
  • service-layer normalization
  • normalized persistence during user creation
  • consistent identity resolution across auth flows

Proof of Work

API Response / Screenshots

Scenario: Case/whitespace-insensitive signup + login

image

Request 2 — POST /api/v1/auth/signup

image

---

### Login lookup normalization

The following inputs now resolve to the same identity:

- `" YELLOW@YOPMAIL.COM "`
- `"yellow@yopmail.com"`

</details>

---

## Test Cases

- [ ] Test case 1: `test_signup_email_is_normalized_to_lowercase_and_trimmed`
- [ ] Test case 2: `test_login_email_is_normalized_to_lowercase_and_trimmed`
- [ ] Test case 3: `test_forgot_password_email_is_normalized_to_lowercase_and_trimmed`
- [ ] Test case 4: `test_resend_verification_email_is_normalized_to_lowercase_and_trimmed`
- [ ] Test case 5: `test_normalize_email_trims_and_lowercases`
- [ ] Test case 6: `test_create_user_stores_normalized_email`

<details>
<summary>Test output</summary>

```bash


Checklist

  • My branch follows the naming convention (<type>/<short-description>)
  • My commits follow Conventional Commits
  • I have added meaningful tests that cover success and failure paths
  • All new and existing tests pass locally (uv run pytest)
  • I have included proof of work (JSON responses or screenshots)
  • I have updated documentation if needed
  • My code follows the project's style guidelines

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 21, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 6312d91d-3353-4c33-8fce-081878ab8ef0

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch dev

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Benji918 Benji918 merged commit 6ffacbe into staging May 21, 2026
7 checks passed
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.

3 participants