feature/account-phone-login #7
Loading…
x
Reference in New Issue
Block a user
No description provided.
Delete Branch "feature/account-phone-login"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📝 进度说明
规格与工单拆分已完成:
.scratch/account-phone-login/spec.md.scratch/account-phone-login/issues/01–05当前状态:01 号工单(新增手机号字段与校验)正在独立 worktree 中实现,尚未合并。02/03/04/05 按依赖关系依次跟进。这个 PR 目前还没有实际功能改动,暂不建议部署到 Fanyu;会在全部工单完成、代码评审通过、合并回
dev后走正常发布流程部署。Expand step of the account-phone-login migration (ticket 01): adds UserRecord.Phone, a sparse phone_unique Mongo index, a China mainland mobile regex validator (^1[3-9]\d{9}$), FindUserByPhone (Mongo + memory), and phone uniqueness helpers (ensureUserPhoneAvailableLocked, validateUserPhoneAvailable) mirroring the existing Email plumbing. Nothing wires Phone into login, account creation, or account editing yet — Email remains the sole identifier used by existing flows, so behavior is unchanged from a user's perspective. That's tickets 02/03/05. Verified: go build ./... clean; new tests (TestMemoryStoreFindUserByPhoneAndEnforcesUniqueness, TestIsValidChinaMobilePhone, TestValidateUserPhoneAvailable) pass; full internal/api suite has the same 75 pre-existing failures (identical names) before and after this change. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>Wires the Phone field/validation/uniqueness helpers added in ticket 01 into the account-management create/edit path, per the account-phone-login migration spec. Backend (internal/api/server.go, internal/domain/types.go, internal/store/{memory,mongo}.go, internal/api/store_errors.go): - handleUsersCreate/handleUsersUpdate now validate and enforce phone (^1[3-9]\d{9}$, uniqueness) instead of email; duplicate-phone errors return field "phone" with no "邮箱" wording. - CreateUserInput gained a Phone field, wired through both store backends' CreateUser. - Email remains on UserRecord (still used by login/self-profile, untouched here) but is no longer required/validated on account create/edit. Frontend (src/pages/Users.tsx, src/services/api/users.ts, src/types.ts, src/context/UserContext.tsx): - Account management create/edit form, search box, and table column switch from email to phone (type="tel", client-side ^1[3-9]\d{9}$ validation, Chinese labels updated to "手机号"). - User type gained an optional `phone` field; usersApi.create's payload field renamed from email to phone to match. - UserContext's createUser helper type/impl updated to match (dead code today, unused by any caller, but kept building); login/session bootstrap logic in UserContext.tsx is untouched. Explicitly out of scope, per the research notes' scope boundary and spec decision 7: the real "存量账号迁移" (migrating Fanyu's live accounts to real phone numbers) is a human-supervised, deployment-time operation, not something this session executed. No production Fanyu Mongo/kubeconfig was touched. This ticket only makes the admin UI/API *capable* of setting a phone number on new or existing accounts, verified against the in-memory store and local fixtures. Also left untouched, per scope: login page/flow, auth.ts, UserContext's login/session logic (ticket 03); Sidebar.tsx, ProjectMembersPanel.tsx, UserBootstrapPanel.tsx (ticket 04). Verified: go build ./... clean; go vet ./... clean; gofmt clean on touched files; go test ./internal/api/... and ./internal/store/... produce the exact same 75 pre-existing failing test names as the ticket-01 baseline (only two account/edit-adjacent tests updated to assert phone instead of email behavior, plus a new TestUserPhoneValidationAndUniquenessOnCreateAndEdit covering create/edit phone format + uniqueness + role/supplier preservation); npm run lint:web (tsc --noEmit) clean; node --test tests/frontend/*.test.mjs matches the pre-existing baseline exactly (599 tests, 586 pass, 13 fail, identical failing test names). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>handleAuthLogin, bootstrap-super-admin, and the login UI now use phone instead of email. Also converts the legacy /api/admin/organizations/{id}/users account-creation endpoint to phone (same-class gap as found while merging ticket 02/04 — it would have created accounts unable to log in once login became phone-only). net/mail is now fully removed from internal/api. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>✅ 全部完成,可以评审了
5 张工单全部实现并合并(01→02→03→04→05,expand-migrate-contract),标准/规格两轴代码评审已跑完,发现的问题都已修复并重新验证。
实现内容:
^1[3-9]\d{9}$)彻底替换邮箱,作为账号登录标识Email字段、email_unique索引、net/mail校验代码全部删除/api/admin/organizations/{id}/users),避免建出无法登录的账号代码评审修复:两个并行子agent独立发现同一个真实回归——
supplier_deletion.go的 Mongo 字段投影漏了phone,导致真实库上供应商删除审计会显示空手机号;另外清理了一处死代码、把重复的手机号正则提取成共享模块、给资料自助编辑表单补上了跟账号管理页一致的前端校验。验证:
go build/go vet全干净;go test ./internal/api/... ./internal/store/... ./internal/domain/...失败数与合并前基线(75项)逐条比对完全一致,无回归;前端tsc --noEmit干净,test:frontend599/586/13 与基线一致。明确没做的:泛宇生产环境真实账号数据迁移——按规格决策 7,这是代码评审通过、合并到
dev之后的独立部署时操作,本次 PR 全程没有连接过任何生产 MongoDB 或 kubeconfig。