Skip to content

feat(register): pass email to verification code request with UX guards - #22

Merged
Cho-Geer merged 6 commits into
developfrom
feat/email-verification-code
Sep 18, 2026
Merged

Cho-Geer merged 6 commits into
developfrom
feat/email-verification-code

Conversation

@Cho-Geer

Copy link
Copy Markdown
Owner

Summary

  • REGISTER flow passes the form email to POST /auth/send-verification-code (sendCode(phoneNumber, type, email?); email omitted from payload for login — strict toStrictEqual guards).
  • Resend countdown starts only after the code request succeeds — on failure (e.g., 409 EMAIL_EXISTS / 429) the UI shows only the error banner: no code input, no countdown, no state change (Register + Login pages).
  • Register email field is now required (zod) with label「邮箱(必填)」; resend button also validates email errors.
  • e2e helper reads the new type-scoped Redis key (verification_code:{type}:{phone}) and new label.

Test evidence

  • jest 109 passed (14 suites) / tsc --noEmit 0 errors / lint:check 0 errors
  • Browser-verified real payloads: register sends email (initial + resend), login omits it; 409/429 paths leave UI unchanged
  • Full Playwright e2e requires backend+Redis running (helper updates included, execution pending integrated environment)

Notes

  • Depends on backend PR (API contract: email required for register, type-scoped Redis keys).
  • Multi-agent flow: implementation + high-precision review iterations to PASS.
  • Non-blocking follow-ups: stale excluded LoginPage.test.js countdown assertions (pre-existing exclusion), resend button type="button" (pre-existing), diverged api-contract copies sync.

TraeAI added 6 commits September 17, 2026 23:49
sendCode now forwards an optional email to POST /auth/send-verification-code; register requires it (server-side 400 validation) while login omits the field entirely to keep the existing payload contract. Email is validated as required in RegisterForm (schema, resend gating, label) and the e2e helper reads the type-scoped Redis key.
The login sendCode case now pins the exact api.post payload with toStrictEqual (which, unlike toHaveBeenCalledWith, distinguishes a present-but-undefined key from an absent one), and the register case is renamed to describe what it actually verifies. The e2e helper comment no longer claims login codes are delivered by SMS.
sendCode omits the email field for empty strings as well as undefined, matching RegisterForm's .min(1) validation and the backend's 400 rejection of empty register emails.
The countdown fired synchronously after dispatch, so a rejected request
(duplicate email, cooldown, network error) still showed a 60s countdown and
had to be inferred from the error banner. Await the sendCode thunk and start
the countdown only on fulfilled, keeping the code input hidden and the
countdown at 0 on failure.

- RegisterPage: await dispatch(sendCode(...)) and gate setCountdown(60) on
  sendCode.fulfilled.match(result)
- userSlice.test: assert rejected sendCode surfaces the backend business
  message in state.error with showCodeInput/codeSent false, and that fulfilled
  flips both flags
@Cho-Geer
Cho-Geer merged commit 8596eff into develop Sep 18, 2026
5 checks passed
@Cho-Geer
Cho-Geer deleted the feat/email-verification-code branch September 26, 2026 02:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant