fix(user): IsPhone validation and single-field login lookup#129
Merged
Conversation
Replace $or collection scan with prioritized lookups by login format so phone, email, and username each hit their partial unique indexes. Co-authored-by: Cursor <cursoragent@cursor.com>
Use regex-based phone validation for user writes and auth phone DTOs. Replace findByLogin $or/fallback with detectLoginField + one indexed query. Co-authored-by: Cursor <cursoragent@cursor.com>
Treat all phone numbers with one pattern: optional +, digits, separators, and 6-15 digit length. Co-authored-by: Cursor <cursoragent@cursor.com>
tylor-zhang
approved these changes
Jun 16, 2026
tylor-zhang
pushed a commit
that referenced
this pull request
Jun 16, 2026
🤖 I have created a release *beep* *boop* --- ## [2.28.1](v2.28.0...v2.28.1) (2026-06-16) ### Bug Fixes * **user:** IsPhone validation and single-field login lookup ([#129](#129)) ([772bc56](772bc56)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
isPhone/@IsPhone/detectLoginField(正则,无新依赖):支持中国 11 位手机号(含连字符/空格)及+开头的国际号UserDoc.phone及 auth 相关 phone DTO(验证码登录、手机注册、重置密码)写入时校验格式findByLogin改为判定 login 类型后只查一个字段(email / phone / username),无 fallback,避免错登和$or全表扫描登录判定规则
@{ email }{ phone }{ username }Test plan
validate.test.spec.ts、user.service.spec.ts通过npm test61 个用例通过findByLogin不再出现 COLLSCANusername/email/phone索引存在