Repository navigation
Commit fdd0641
fix(auth): the sign-in page reads the sign-in methods the server has now after sign-out (#30413)
<!-- claude-projects-attribution: {"github_login":"os-bill"} -->
_Requested by **Bill** · [project
thread](https://claude.ai/code/project/chan_016iMXWSZDzqWRWvWzdNo8wg?thread=cmsg_016iMXWSZDzqWRWvWzdNo8wg2F51sfb77qcGc98qsmi8jZ)_
domain:ui#3 · os-bill · session_01Utp6CbPN5UYMnBaNJPJWfG
Refs #30299
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 改了什么:管理员在设置页关掉邮箱密码登录、登出后,登录页不再画邮箱密码表单,改为显示服务端现在真正开着的登录方式(如 Google)。
- 为什么改:前端把登录配置缓存到页面刷新为止;设置可以热改后,同一标签页登出看到的是旧配置,表单点了也会被服务端拒绝。
- 风险与回滚:只改 `@object-ui/auth` 的配置缓存:登出或读不到会话时丢弃缓存,登录状态内行为不变;回滚即撤本 PR。
- 先看:`ui/packages/auth/src/createAuthClient.ts` 的 `forgetConfig`
两个调用点(`signOut` 开头、`getSession` 返回空之前)。
- 两分钟验证:`pnpm --dir ui exec vitest run
packages/auth/src/__tests__/createAuthClient.test.ts`,预期 36 条全过。
- 需要你做的:无,席位落地;「关闭前确认」需要 settings-manifest 新键,席位另开卡。
## What changes
`createAuthClient().getConfig()` single-flights and caches
`/auth/config`. The cache's comment said the config is static per server
boot, and it lived for the page's whole life. It is no longer static:
the Authentication settings page turns email and password and the Google
provider on and off while the server runs, and `/auth/config` answers
the new set at once. An administrator who turned email and password off
(with Google configured) and signed out inside the console was shown the
email and password form from the copy read while signed in, and no
Google button.
The cache now lives for one signed-in stretch. A new closure helper,
`forgetConfig()`, drops it:
- at the start of `signOut()` (before the request, so a failed sign-out,
which still clears the token, forgets it too);
- when `getSession()` finds no session (an expired session reaches the
sign-in page without a sign-out).
Readers on one page still share one request, and nothing changes while a
session lasts. Both login hosts read the config through this client, so
the console's own sign-in page is covered without touching it.
What this card's two Wanted items get here:
- Item 1, first half (the server's refusal text): already holds on
`main`, measured below. The floor's refusal arrives as `400
SETTINGS_VALIDATION` with one `details.fields` entry carrying the
localized message; the settings page draws it under the "Enable
email/password login" row and toasts "1 setting needs attention: Enable
email/password login". No change needed.
- Item 1, second half (confirm before turning email and password off):
NOT in this PR, by the seat's ruling. The settings page is a generic
manifest renderer and a toggle specifier has no confirm key; the honest
home is a new settings-manifest key, which is spec work, so it goes to
its own card. Hard-coding `auth.email_password_enabled` in the renderer
was ruled out.
- Item 2 (login page draws the form when `emailPassword.enabled` is
false): the cause was the stale client cache above, not the dev sign-in
chip. `LoginForm` already collapses the form on `enabled === false`; it
was handed the old answer.
## Tests
- `ui/packages/auth/src/__tests__/createAuthClient.test.ts`, new
top-level describe in the existing harness: the cached config is kept
while the session lasts (one request), and read again after `signOut()`;
and read again after `getSession()` answers no session.
- Reverse verification: with the base `createAuthClient.ts` restored
over the committed test, both new cases go red (2 failed, 34 passed);
restored by `git checkout HEAD`, hash matched HEAD's blob.
## Acceptance notes
- Measured live on an own stack: `examples/app-showcase` `objectstack
dev --seed-admin --fresh -p 4317` plus the console dev server on 5317,
Playwright driving the real pages. Scenario: sign in, Setup, Settings,
Authentication; turn email and password off and save (refused, row
message shown); add Google client ID and secret in the same draft and
save (accepted, `/auth/config` then reports `emailPassword.enabled:
false` and a Google provider); sign out from the account menu.
- Before (base client): sign-in page draws Email and Password and the
Sign In button, no Google button; no `/auth/config` request after
sign-out.
- After (this branch): one `/auth/config` request after sign-out
answering `enabled: false`; the page draws "Continue with Google" and no
email field.
- Out of scope, for the seat to file: the dev "Sign in as dev admin"
chip on the console sign-in page is still offered when email and
password are off, and it signs in with email and password, which the
server refuses. It lives in the console sign-in page, held by another
card.
- Out of scope, for the seat to file: the settings spec declares
`confirmText` on `action_button` handlers, and the console settings
field never reads it, so an action declared with a confirmation runs
without one.
## Verification
<details><summary>Unit tests (head 777cbe4; the changed test re-run on
the merge head b395171: 36 passed)</summary>
- `pnpm --dir ui exec vitest run
packages/auth/src/__tests__/createAuthClient.test.ts`: Test Files 1
passed, Tests 36 passed.
- `pnpm --dir ui exec vitest run --maxWorkers=2 packages/auth/`: Test
Files 44 passed, Tests 383 passed.
- The 16 sign-in page test files under the console and app-shell that
build a real `createAuthClient`: Test Files 16 passed, Tests 103 passed.
</details>
<details><summary>Derived gates: 35 of 35 exit 0 (head 777cbe4),
reconciled by dispatch-gates --ran: 0 NOT-MEASURED, 0 UNRUN</summary>
- `node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack` derived 35 commands from the 3 changed
paths; each was run with its exit code captured before any pipe; all 35
exit 0, including `check-sdui-manifest`, `check:type-check-debt` and
`check:type-check-coverage`.
- After merging `origin/main` (no overlap with this diff), re-run on
b395171: the changeset gates (`check-adr-0087-registration`,
`check-changeset-no-major`, `check-empty-changeset`),
`check-closing-keyword-parity`, `check-sdui-manifest`,
`check:published-files`, `check:nul-bytes`, `check:type-check-coverage`,
`check:type-check-debt`, `check:cross-package-test-inputs`,
`check:test-source-alias`: all exit 0.
- `pnpm exec turbo run type-check --filter=@object-ui/auth
--concurrency=2` (source and test programs): exit 0 on b395171.
- The whole-workspace type-check lanes and Test UI run in CI.
</details>
---
_Generated by [Claude
Code](https://claude.ai/code/session_01Utp6CbP8wvhDVypXfydTzD)_
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 60fe44f commit fdd0641
3 files changed
Lines changed: 83 additions & 7 deletions
File tree
- .changeset
- ui/packages/auth/src
- __tests__
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
558 | 558 | | |
559 | 559 | | |
560 | 560 | | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
561 | 607 | | |
562 | 608 | | |
563 | 609 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
491 | 491 | | |
492 | 492 | | |
493 | 493 | | |
494 | | - | |
495 | | - | |
496 | | - | |
497 | | - | |
498 | | - | |
499 | | - | |
500 | | - | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
501 | 509 | | |
502 | 510 | | |
503 | 511 | | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
504 | 515 | | |
505 | 516 | | |
506 | 517 | | |
| |||
649 | 660 | | |
650 | 661 | | |
651 | 662 | | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
652 | 668 | | |
653 | 669 | | |
654 | 670 | | |
| |||
721 | 737 | | |
722 | 738 | | |
723 | 739 | | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
724 | 744 | | |
725 | 745 | | |
726 | 746 | | |
| |||
0 commit comments