Repository navigation
Commit a7293f7
fix(plugin-auth): a sign-up answers without waiting for any mail send, whether or not the address already has an account (#29975)
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 改了什么:注册接口 `POST /api/v1/auth/sign-up/email`
不再等任何邮件发送完成就作答——新地址的验证邮件、以及发给已有账号地址的提醒邮件,都改在响应之后发出,沿用找回密码邮件已在用的同一个助手。
- 为什么改:注册无论地址是否已有账号,都应一样作答、不等发信;这与找回密码请求已落地的规则一致。
- 风险与回滚:响应后才发信,进程若在响应与发信之间退出会丢这封信(与原先请求中途退出等价);重发验证邮件接口仍同步等待并如实报错。回滚即
revert 本 PR。
- 先看:`auth-manager-auth-instance.ts` 里的 `sendAfterResponseOnSignUp`
与两个回调的包装;`signup-existing-address-success-shape.test.ts` 的 ⑦
组;`run-after-response.ts` 的日志一行。
- 两分钟验证:`pnpm --filter @objectstack/plugin-auth exec vitest run
src/signup-existing-address-success-shape.test.ts`,预期 18 个用例全绿。
- 需要你做的:无,席位落地。
## What changes
- **The rule.** `POST /api/v1/auth/sign-up/email` answers without
waiting for any mail send, whether or not the address already has an
account. On the public door (a call that carries its request) the
verification mail and the notice to an address that already has an
account are built and sent after the response, through
`sendAfterResponseOnPublicDoor`, the helper the password-reset mail
already uses. A send that fails is logged on the server at error and
never reaches the caller, whose answer is the one a sent mail gets.
- **Only the sign-up's verification send moves.** The verification-mail
callback serves more doors than sign-up, so `sendAfterResponseOnSignUp`
hands the helper only the call the sign-up endpoint makes, read by the
endpoint's declared path from better-auth's endpoint context (as the
hooks read `ctx.path`), never from the request URL. Every other call is
awaited exactly as before, above all `/send-verification-email`, which
still reports a failed send to its caller. Outside any endpoint context
the call is awaited.
- **A server-side call is unchanged.** `auth.api.signUpEmail` carries no
request and still awaits both sends.
- **The failure log names its medium in `what`.**
`logAfterResponseSendFailure` now prints `what` as given
(`password-reset email`, `verification email`, `sign-up notice email`).
This hunk, and the reset call site's `what`, are byte-identical to the
sibling draft that moves the phone reset text, so the two merge cleanly
in either order (`git merge-tree` against its head: no conflict). The
reset's own log line reads exactly as before. The notice keeps its own
error line for a failed send and never throws; `onFailure` is its
backstop.
- **Unchanged.** The answer's status and body, the sign-up rate limits,
the mails themselves.
## Tests
- `signup-existing-address-success-shape.test.ts` gains ⑦, one top-level
`describe` in the existing harness file:
- with `sendOnSignUp` off and on, both kinds of address get the same
answer while every send is held open by a deferred, and the mail still
goes out once it is released;
- a verification send that fails is logged on the server at error, and
the sign-up answers as one whose mail is sent;
- the server-side sign-up call (no `Request`) still awaits its sends;
- the `/send-verification-email` resend still awaits its send and
answers 500 for one that failed.
- The existing pins ①, ②, ⑤ and ⑥ wait for the mail to arrive
(`vi.waitFor`) before reading it; what each asserts is unchanged. The
negative mail assertions in ②, ③ and ④ follow an explicit refusal, where
no send is ever scheduled.
## Acceptance notes
- A consumer that reads the verification mail the instant the sign-up
answers now sees it a moment later; the plugin-auth suite has no such
reader left, and a `git grep` over test files outside this package finds
none.
- Ablation (one-shot, each leg restored and proven by blob hash):
removing the notice wrapper reds both ⑦ answer cases; removing the
verification wrapper reds the `sendOnSignUp on` answer case and the
failure-log case; wrapping every verification call reds the resend case.
Removing a wrapper fails by the case timeout, because the answer then
waits on the held send.
## Verification
<details><summary>plugin-auth suite at 7a467a8</summary>
```
pnpm --filter @objectstack/plugin-auth test (under scripts/pm/os-verify-lock.sh)
Test Files 219 passed (219)
Tests 3771 passed | 10 skipped (3781)
os-verify-lock: VERDICT command-exit 0
```
</details>
<details><summary>plugin-auth typecheck at 7a467a8</summary>
```
pnpm --filter @objectstack/plugin-auth typecheck (under scripts/pm/os-verify-lock.sh)
check:test-typecheck: OK — 10 file(s) / 88 error(s) / 23 pinned signature(s) held in test-typecheck-debt.json
os-verify-lock: VERDICT command-exit 0
```
</details>
<details><summary>Ablation at 6a399c2 (source identical at
7a467a8)</summary>
```
leg notice (onExistingUserSignUp wrapper removed) exit 1 · 2 failed | 3 passed (⑦ only) · restored: blob == HEAD
leg verify (sendVerificationEmail wrapper removed) exit 1 · 2 failed | 3 passed (⑦ only) · restored: blob == HEAD
leg wrap-all (every verification call after the response) exit 1 · 1 failed | 4 passed (⑦ only) · restored: blob == HEAD
```
</details>
<details><summary>Derived gates at 7a467a8</summary>
```
node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack # 59 commands, tree 7a467a8
# every command run, exit code captured before any pipe; reconciled with --ran:
# 59 derived famil(ies) accounted for — 58 run, 1 NOT-MEASURED (1 DERIVED from a recorded exit 3)
node scripts/check-adr-0087-registration.mjs --base origin/main :: exit 0
node scripts/check-adr-0087-registration.mjs --self-test :: exit 0
node scripts/check-changeset-no-major.mjs --base origin/main :: exit 0
node scripts/check-closing-keyword-parity.mjs :: exit 0
node scripts/check-closing-keyword-parity.mjs --self-test :: exit 0
node scripts/check-comment-mask-adoption.mjs :: exit 0
node scripts/check-comment-mask-adoption.mjs --self-test :: exit 0
node scripts/check-comment-mask-corpus.mjs :: exit 0
node scripts/check-dev-prereqs.mjs --self-test :: exit 0
node scripts/check-dts-emitted.mjs --self-test :: exit 0
node scripts/check-empty-changeset.mjs --base origin/main :: exit 0
node scripts/check-empty-changeset.mjs --self-test :: exit 0
node scripts/check-issue-citations.mjs :: exit 0
node scripts/check-plugin-teardown-shape.mjs :: exit 0
node scripts/check-plugin-teardown-shape.mjs --self-test :: exit 0
node scripts/check-tenant-audit-census.mjs :: exit 0
node scripts/check-tenant-audit-census.mjs --self-test :: exit 0
node scripts/ci/assert-turbo-remote-cache.mjs --self-test :: exit 0
node scripts/ci/plan-test-core-shards.mjs --self-test :: exit 0
node scripts/ci/prune-turbo-cache.mjs --self-test :: exit 0
node scripts/docs-audit/check-affected-docs.mjs :: exit 0
node scripts/docs-audit/check-drift-comment.mjs :: exit 0
node scripts/pm/release-rehearsal-clone.mjs --self-test :: exit 0
node scripts/release-pending-publish.mjs --self-test :: exit 0
pnpm --filter @objectstack/spec run check:duration-unit-keys :: exit 0
pnpm check:changeset-gate-self-tests :: exit 0
pnpm check:ci-filter-parity :: exit 0
pnpm check:closed-ceremony-text :: exit 0
pnpm check:cross-package-test-inputs :: exit 0
pnpm check:doc-authoring :: exit 0
pnpm check:driver-memory-census :: exit 0
pnpm check:dts-closure :: exit 0
pnpm check:engine-double-contract :: exit 0
pnpm check:gitlink-declared :: exit 0
pnpm check:issue-citations :: exit 0
pnpm check:keyed-text-bounds :: exit 0
pnpm check:lean-entry-closure :: exit 0
pnpm check:logger-receiver-detach :: exit 0
pnpm check:nul-bytes :: exit 0
pnpm check:objectql-double-limit :: exit 0
pnpm check:org-identifier :: exit 0
pnpm check:page-declaration-shape :: exit 0
pnpm check:platform-object-tenancy-census :: exit 0
pnpm check:published-files :: exit 0
pnpm check:query-options-erasure :: exit 0
pnpm check:refd-timer-probe :: exit 0
pnpm check:registry-log-declared :: exit 0
pnpm check:rest-log-spy-declared :: exit 0
pnpm check:slot-lookup :: exit 0
pnpm check:sourcemap-no-sources-content :: exit 0
pnpm check:system-context-census :: exit 0
pnpm check:test-source-alias :: exit 0
pnpm check:tier-file-adoption :: exit 0
pnpm check:type-check-coverage :: exit 0
pnpm check:type-check-debt :: exit 0
pnpm check:undeclared-dep-imports :: exit 0
pnpm check:watch-hint-literal :: exit 0
pnpm check:where-matcher :: exit 0
pnpm check:dual-build-cjs-loads :: exit 3 # PREREQUISITE NOT MET: reads every package dist/, this tree built plugin-auth and its closure only
# NOT MEASURED locally; Lint & Repo Gates runs it. Targeted substitute: require() of plugin-auth dist/index.js loads (160 exports).
# also run, rosters under the changed paths (outside the derivation):
pnpm check:auth-mount-ledger :: exit 0
pnpm check:authz-resolver :: exit 0
pnpm check:changeset-fixed :: exit 0
pnpm check:error-code-casing :: exit 0
pnpm check:filter-alias-parity :: exit 0
```
</details>
## CI note (seat)
- `Type Check · workspace` on `7a467a8031` failed because `Checkout
repository` timed out after 20 minutes, before any step ran on the code
(the same runner-side timeout hit merge-group run 41719580038 the same
hour). Treated as a flake and re-run once through the relay.
- `Check Changeset` on this head was cancelled with no superseding run;
this body edit re-triggers it.
<!-- signed: security#1 · os-justin · session_01QSeKYn5CmmdShCJifm6WYj
-->
---------
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: objectstack-fleet[bot] <332303061+objectstack-fleet[bot]@users.noreply.github.com>1 parent 5cdaddb commit a7293f7
3 files changed
Lines changed: 226 additions & 14 deletions
File tree
- .changeset
- packages/plugins/plugin-auth/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
| 55 | + | |
55 | 56 | | |
56 | 57 | | |
57 | 58 | | |
| |||
70 | 71 | | |
71 | 72 | | |
72 | 73 | | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
73 | 106 | | |
74 | 107 | | |
75 | 108 | | |
| |||
505 | 538 | | |
506 | 539 | | |
507 | 540 | | |
508 | | - | |
509 | | - | |
510 | | - | |
| 541 | + | |
| 542 | + | |
511 | 543 | | |
512 | 544 | | |
513 | 545 | | |
514 | 546 | | |
515 | 547 | | |
516 | | - | |
517 | | - | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
518 | 563 | | |
519 | 564 | | |
520 | 565 | | |
| |||
530 | 575 | | |
531 | 576 | | |
532 | 577 | | |
533 | | - | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
534 | 587 | | |
535 | 588 | | |
536 | 589 | | |
| |||
579 | 632 | | |
580 | 633 | | |
581 | 634 | | |
582 | | - | |
| 635 | + | |
583 | 636 | | |
584 | 637 | | |
585 | 638 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
31 | 41 | | |
32 | 42 | | |
33 | 43 | | |
34 | 44 | | |
35 | 45 | | |
36 | | - | |
| 46 | + | |
37 | 47 | | |
38 | 48 | | |
39 | 49 | | |
| |||
246 | 256 | | |
247 | 257 | | |
248 | 258 | | |
249 | | - | |
| 259 | + | |
250 | 260 | | |
251 | 261 | | |
252 | 262 | | |
| |||
260 | 270 | | |
261 | 271 | | |
262 | 272 | | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
263 | 277 | | |
264 | 278 | | |
265 | 279 | | |
| |||
301 | 315 | | |
302 | 316 | | |
303 | 317 | | |
304 | | - | |
| 318 | + | |
| 319 | + | |
305 | 320 | | |
306 | 321 | | |
307 | 322 | | |
| |||
330 | 345 | | |
331 | 346 | | |
332 | 347 | | |
333 | | - | |
| 348 | + | |
334 | 349 | | |
335 | 350 | | |
336 | 351 | | |
| |||
391 | 406 | | |
392 | 407 | | |
393 | 408 | | |
394 | | - | |
| 409 | + | |
395 | 410 | | |
396 | 411 | | |
397 | 412 | | |
| |||
402 | 417 | | |
403 | 418 | | |
404 | 419 | | |
405 | | - | |
| 420 | + | |
| 421 | + | |
406 | 422 | | |
407 | 423 | | |
408 | 424 | | |
| |||
416 | 432 | | |
417 | 433 | | |
418 | 434 | | |
| 435 | + | |
419 | 436 | | |
420 | 437 | | |
421 | 438 | | |
422 | 439 | | |
423 | 440 | | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
0 commit comments