Skip to content

User model: fragile use of arguments.length in findByEmailOrUsername #3911

@Nixxx19

Description

@Nixxx19

p5.js version

No response

What is your operating system?

None

Web browser and version

No response

Actual Behavior

findByEmailOrUsername() uses arguments.length === 2 to decide whether to use case-insensitive behavior. This is fragile: it can break with default parameters, extra arguments, or different call styles. Modern practice is to use explicit parameter checks.

Location: server/models/user.tsfindByEmailOrUsername() line 291

Expected Behavior

Case-insensitive behavior should be controlled by explicitly checking the options parameter (e.g. options && typeof options === 'object' && options.caseInsensitive) instead of arguments.length.

Steps to reproduce

Steps:

  1. Open server/models/user.ts and find findByEmailOrUsername.
  2. Note the condition arguments.length === 2 && typeof options === 'object' && options.caseInsensitive.
  3. Consider calling with default args or from a wrapper that passes a third argument; behavior may be inconsistent.

Snippet:

// user.ts - findByEmailOrUsername
if (
  arguments.length === 2 &&
  typeof options === 'object' &&
  options.caseInsensitive
) {
  // case-insensitive branch
}

Metadata

Metadata

Assignees

Labels

BugError or unexpected behaviors

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions