Skip to content

fix: user model findbyemailorusername options handling#3931

Open
Nixxx19 wants to merge 2 commits intoprocessing:developfrom
Nixxx19:nityam/fix-user-findbyemailorusername
Open

fix: user model findbyemailorusername options handling#3931
Nixxx19 wants to merge 2 commits intoprocessing:developfrom
Nixxx19:nityam/fix-user-findbyemailorusername

Conversation

@Nixxx19
Copy link
Contributor

@Nixxx19 Nixxx19 commented Feb 24, 2026

Issue:

Fixes #3911

The findByEmailOrUsername static on the User model currently uses arguments.length === 2 to decide when to apply case-insensitive behavior. This is fragile and can break if the function is called with default parameters or extra arguments. The behavior should instead be controlled explicitly via the options parameter.

Changes:

  • Updated server/models/user.ts findByEmailOrUsername to:
    • Remove the arguments.length === 2 check.
    • Use an explicit, options-based condition: if (options && typeof options === 'object' && options.caseInsensitive).
  • Kept the existing API shape: callers still pass an optional options object with caseInsensitive and valueType.

I have verified that this pull request:

  • has no linting errors (npm run lint)
  • has no test errors (npm run test)
  • has no typecheck errors (npm run typecheck)
  • is from a uniquely-named feature branch and is up to date with the develop branch. (nityam/fix-user-findbyemailorusername)
  • is descriptively named and links to an issue number, i.e. Fixes #3911
  • meets the standards outlined in the accessibility guidelines

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.

User model: fragile use of arguments.length in findByEmailOrUsername

1 participant