fix: accounts-passwordless case-insensitive email and audit-argument-checks#14274
fix: accounts-passwordless case-insensitive email and audit-argument-checks#14274dupontbertrand wants to merge 3 commits intometeor:develfrom
Conversation
…#12412) Use Accounts._findUserByQuery for case-insensitive user lookup during login, and compare emails case-insensitively when verifying tokens. Fixes meteor#12412
✅ Deploy Preview for v3-meteor-api-docs canceled.
|
✅ Deploy Preview for v3-migration-docs canceled.
|
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughDelegates user lookup to Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/accounts-passwordless/passwordless_server.js`:
- Line 109: The function parameter formatting for requestLoginTokenForUser is
lint-breaking; remove the unnecessary parentheses around the single async
parameter. Locate the requestLoginTokenForUser: async (args) => { definition and
change it to use the single-parameter concise form (requestLoginTokenForUser:
async args => {) so Prettier/CI is satisfied.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: fe2079ca-f09e-4365-a08a-41a86ece5198
📒 Files selected for processing (1)
packages/accounts-passwordless/passwordless_server.js
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/accounts-passwordless/passwordless_server.js (1)
110-114: ConsiderMatch.ObjectIncludingto future-proof strict arg validation.
check(args, { ... })enforces an exact object shape. While the current codebase has no callers passing extra top-level keys, usingMatch.ObjectIncludingaligns with defensive patterns for core packages—especially given this API already involves a signature change from destructured parameters to a single object.Suggested improvement
- check(args, { + check(args, Match.ObjectIncluding({ selector: Accounts._userQueryValidator, userData: Match.Optional(Object), options: Match.Optional(Object), - }); + }));🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/accounts-passwordless/passwordless_server.js` around lines 110 - 114, The check call in passwordless_server.js currently enforces an exact args shape (check(args, { selector: Accounts._userQueryValidator, userData: Match.Optional(Object), options: Match.Optional(Object) })); update it to use Match.ObjectIncluding so extra top-level keys are allowed: wrap the existing shape with Match.ObjectIncluding(...) to accept the current fields while tolerating future additions; keep the same validators (Accounts._userQueryValidator, Match.Optional(Object)) and only change the outer check invocation to Match.ObjectIncluding to future-proof the API.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@packages/accounts-passwordless/passwordless_server.js`:
- Around line 110-114: The check call in passwordless_server.js currently
enforces an exact args shape (check(args, { selector:
Accounts._userQueryValidator, userData: Match.Optional(Object), options:
Match.Optional(Object) })); update it to use Match.ObjectIncluding so extra
top-level keys are allowed: wrap the existing shape with
Match.ObjectIncluding(...) to accept the current fields while tolerating future
additions; keep the same validators (Accounts._userQueryValidator,
Match.Optional(Object)) and only change the outer check invocation to
Match.ObjectIncluding to future-proof the API.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 7c3dbd8e-dbc0-461d-8445-befdf209c3e4
📒 Files selected for processing (1)
packages/accounts-passwordless/passwordless_server.js
Summary
Fixes #12412
Fixes #12053
Two related fixes in
accounts-passwordless:Case-insensitive email lookup (#12412)
findUserWithOptions: replaced direct{ 'emails.address': email }query withAccounts._findUserByQuery, which performs a case-insensitive fallback lookup — matching the behavior already used byrequestLoginTokenForUsercheckToken: use the storedtokenEmail(from DB) for the SHA256 hash instead ofselector.email, and compare emails case-insensitively with.toLowerCase()The root cause was an asymmetry:
requestLoginTokenForUserused_findUserByQuery(case-insensitive) to find the user and generate a token, but the login handler used a direct query (case-sensitive) to verify the token. When a user signed up with[email protected]and later tried to log in with[email protected], the token was generated successfully but the login failed with "User not found [403]".audit-argument-checks compatibility (#12053)
check()validation to therequestLoginTokenForUsermethod arguments, so it no longer throwsDid not check() all argumentswhen theaudit-argument-checkspackage is installed.Test plan
[email protected], logout, login with[email protected]— now worksaudit-argument-checksinstalled — no moreInternal server errorSummary by CodeRabbit
Bug Fixes
Tests