Skip to content

Trim the identifier in user repository lookups (#574) - #578

Merged
silverbackdan merged 4 commits into
mainfrom
fix/574-trim-identifier
Oct 31, 2026
Merged

silverbackdan merged 4 commits into
mainfrom
fix/574-trim-identifier

Conversation

@silverbackdan

Copy link
Copy Markdown
Collaborator

Fixes #574.

UserRepository lower-cased identifiers but did not trim them, so a trailing space from a mobile keyboard failed sign-in ("user " → 401) and made password reset and resend verification a 404.

  • loadUserByIdentifier() (and so loadUserByUsername(), json_login, password reset, resend verification and new email resend), findOneByEmail(), findOneWithPasswordResetToken() and findOneByUsernameAndNewEmailAddress() (both arguments) now compare strtolower(trim(...)).
  • FindUserByUsernameTrait compares the returned username with the trimmed query, otherwise a trimmed match would be refused there (verify email, change password, new email address, UserPassword).

Tests:

  • Functional: sign-in with "user ", " USER" and "user@example.com " (SecurityTest), password reset request and resend verification with my_username%20.
  • Unit: UserRepositoryTest (each lookup on an in-memory database) and FindUserByUsernameTraitTest.

🤖 Generated with Claude Code

@codecov

codecov Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.05%. Comparing base (6f07272) to head (efbc05d).

Additional details and impacted files
@@             Coverage Diff              @@
##               main     #578      +/-   ##
============================================
+ Coverage     97.04%   97.05%   +0.01%     
  Complexity     5302     5302              
============================================
  Files           433      433              
  Lines         13724    13724              
============================================
+ Hits          13318    13320       +2     
+ Misses          406      404       -2     
Flag Coverage Δ
phpunit 97.05% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@silverbackdan
silverbackdan merged commit b17d7fa into main Oct 31, 2026
14 of 15 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.

UserRepository lookups don't trim the identifier: a trailing space from mobile keyboards fails sign-in and password reset

1 participant