Skip to content

fix: use exact case-insensitive email comparisons 🐞 #910

Open

Description

@levin0710

Description

Follow-up to the review on #907: updateMemberEmail uses ILIKE for ownership lookup and deletion. It interprets _ and % as wildcards rather than literal email characters.

An admin entering john_doe@example.com can match an existing john.doe@example.com. Reusing that row can save an address different from the one entered. Deleting the previous primary can also match the address being promoted and fail on a database constraint. The member-scoped delete added in #907 prevents deleting other members' rows but does not prevent these matches within the same member.

Steps to Reproduce

Use test members to exercise these cases:

  1. Give a member the secondary address john.doe@example.com, then submit john_doe@example.com through Admin → Update Email. The lookup can select the dot address instead of treating the underscore literally.
  2. Give a member primary john_doe@example.com and secondary john.doe@example.com, then promote the dot address. Deleting the old primary can match both addresses.

Expected Behavior

Compare email addresses exactly, ignoring case, without interpreting wildcard characters. Only the requested address should become primary, and only the previous primary should be deleted.

Acceptance Criteria

  • Replace pattern matching in the ownership lookup and previous-primary deletion with exact, case-insensitive comparisons.
  • Preserve member ownership checks, stored spelling, and the member-scoped delete.
  • Verify _ and % are treated literally, case-insensitive matches still work, and promoting a secondary address does not delete it.

Additional Context

Affected code: packages/core/src/modules/members/use-cases/update-member-email.ts.

These cases were identified during review; they have not been independently reproduced in production.

Activity

  1. added
    Bug 🐞
    Backend 🔌
    on Oct 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Backend 🔌Bug 🐞

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions