Skip to content

fix: normalize email to lowercase for member, mentor, and user account persistence - #828

Open
kksingh000 wants to merge 3 commits into
Women-Coding-Community:mainfrom
kksingh000:fix/732-email-case-normalization
Open

kksingh000 wants to merge 3 commits into
Women-Coding-Community:mainfrom
kksingh000:fix/732-email-case-normalization

Conversation

@kksingh000

Copy link
Copy Markdown

Description

MemberMapper.addMember() already lowercased the email before insert, but updateMember() did not. A member who updated their profile with a different casing of their email (e.g. Jane.Doe@Example.com instead of jane.doe@example.com) would end up with a mixed-case email stored, while every lookup path (findByEmail, findIdByEmail, deleteByEmail) queried with a case-sensitive WHERE email = ? against the raw input email, not a lowercased one.

This caused two concrete problems:

  • Duplicate members: a mixed-case email could pass the "already exists" dedupe check (which looks up by raw email) and a second member record would be created for what is effectively the same email address.
  • Login lockout for new accounts: PostgresUserAccountRepository.create() inserted the raw email and then immediately called findByEmail() (which lowercases before querying) to fetch the newly created row. If the email was inserted with mixed case, that lookup would return empty, orElseThrow() would throw, and the transaction would roll back — permanently preventing that user from ever being provisioned or logging in.

Fix

Normalize email to lowercase (Locale.ENGLISH) on every write path, consistent with the read paths that already lowercase before querying:

  • MemberMapper.updateMember()
  • PostgresMemberRepository.findByEmail(), findIdByEmail(), deleteByEmail()
  • PostgresMentorRepository.findByEmail(), findIdByEmail()
  • PostgresUserAccountRepository.create(), update()

Notes

No schema change required. PMD is clean (pmdMain, pmdTest) and the full unit test suite passes locally.

Related Issue

Closes #732

Change Type

  • Bug Fix
  • New Feature
  • Code Refactor
  • Documentation
  • Test
  • Other

Screenshots

N/A — backend data-layer fix, no API contract change.

Pull request checklist

…t persistence

Member, mentor, and user account lookups by email are case-sensitive,
but member creation lowercases the email only on insert, not on
update. User account creation and update write the email as-is while
the lookup used right after lowercases it. A later mixed-case update
or account provisioning silently produces a duplicate member row or
an account that can never be found again.

Normalize to lowercase at every write and read site in MemberMapper,
PostgresMemberRepository, PostgresMentorRepository, and
PostgresUserAccountRepository so all paths use the same canonical
form.

Fixes Women-Coding-Community#732
@sonarqubecloud

sonarqubecloud Bot commented Nov 4, 2026

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
D Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

This branch has not been deployed

No deployments
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.

bug: Inconsistent email case handling causes duplicate members and login lockout

2 participants