- handleAuthLogin now authenticates via store.FindUserByPhone instead of
FindUserByEmail; the login/bootstrap-super-admin request payload field
is now `phone`. Old email addresses are no longer valid login credentials.
- bootstrap-super-admin now validates phone format (isValidChinaMobilePhone)
instead of net/mail.ParseAddress; net/mail is fully removed from
internal/api.
- Same-class gap fix: handleAdminOrganizationUsersCreate (the legacy
per-organization admin endpoint, not touched by ticket 02) still created
users by email only, which would have left them unable to log in under
the new phone-only login. Switched it to phone validation/uniqueness too,
and removed the now-dead normalizeUserInput/validateUserEmailAvailable
helpers.
- Frontend: authApi.login, UserContext's login signature, and
UserBootstrapPanel's submit handler now send `phone` instead of `email`
(the form/labels were already phone-based from ticket 04).
- Updated ~20 Go test files whose fixtures/helpers logged in via
user.Email; adminCreateUser/loginSession/bootstrapSuperAdminSession now
work in terms of phone (deterministically derived from existing
email-shaped test identities via testPhoneFromSeed, to avoid rewriting
every call site). Added internal/api/auth_phone_login_test.go covering
phone login success/failure and old-email rejection.
go test ./internal/api/... and npm run test:frontend match their
pre-ticket baselines exactly (75 Go failures / 599 frontend tests with
586 pass, 13 fail) by failing test name, not just count.
Admin account-management UI and API now validate/enforce phone instead
of email on create/edit. Production Fanyu data migration deferred to
deployment time per spec decision 7 — not executed here.
Merge conflict resolution + gap fixes found while reconciling 02 and 04:
- src/types.ts / UserContext.tsx / users.ts: kept Email required + Phone
optional (matches current migration state — login still uses email
until ticket 03); createUser/updateCurrentUser signatures reconciled
to the versions that are actually wired to real backend behavior.
- internal/api/project_members.go: projectMemberView never exposed
Phone (ticket 04's frontend rename to userPhone had nothing to read).
Renamed UserEmail->UserPhone and populated it from user.Phone.
- internal/store/memory.go + mongo.go: ListProjectMemberUsers's field
whitelist projection dropped Phone entirely (pre-existed the Phone
field, never updated) — same root cause as project_members.go, one
layer down.
- internal/api/auth.go: handleCurrentUserProfileUpdate/
currentUserProfilePatch still only supported Email; self-service
profile edit silently no-opped on phone. Wired to phone validation
mirroring the ticket-02 admin create/edit pattern.
- Updated 3 tests whose expectations depended on the self-profile-update
gap above (TestSessionAuthTenantIsolationAndRolePermissions,
TestUserEmailUniquenessValidation, TestProjectMemberDisplayScopedBatch)
to phone; verified full internal/api suite back to the 75-failure
baseline (byte-identical failing test names) and frontend suite at
599/586/13 baseline.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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>