Skip to content

Commit 35a8f08

Browse files
fix(console): hide the dev admin chip when email and password sign-in is off (#30531)
<!-- claude-projects-attribution: {"github_login":"os-sales"} --> _Requested by **Sales** · [project thread](https://claude.ai/code/project/chan_01D5bWFY3rFzgJcytD5gD4Uu?thread=cmsg_01D5bWFY3rFzgJcytD5gD4UuSsxASUNa88cQKqk6NNZWir)_ Fixes #30420 Clause-②: no Metadata-protocol: none ## 维护者速读 - 改了什么:Console 登录页在服务端关闭邮箱+密码登录时,不再显示「Sign in as dev admin」开发管理员入口。 - 为什么改:该入口用邮箱+密码登录,密码登录关闭时服务端必然拒绝(`EMAIL_PASSWORD_DISABLED`),页面其余部分已只显示 Google 等提供方,入口是误导。 - 风险与回滚:仅 `os dev` 开发环境可见的一行渲染条件,生产从不下发 `devSeedAdmin`;回滚即 revert 本 PR。 - 先看:`ui/apps/console/src/pages/auth/LoginPage.tsx` 中 `DevAdminRow` 的渲染条件;其次测试文件新增两例。 - 两分钟验证:`pnpm --dir ui exec vitest run apps/console/src/pages/auth/__tests__/LoginPage.dev-admin-hint.test.tsx`,预期 12 passed。 - 需要你做的:无,席位落地。 ## What changes - `LoginPage` drew the dev-seeded admin row on `devSeedAdmin` alone. It now draws it only when `/api/v1/auth/config` does not report `emailPassword.enabled: false`, the same answer `LoginForm` reads to hide the password form (`config?.emailPassword?.enabled === false`). The condition reads the `authConfig` state the "Read public auth config" effect already stores; that effect and the "Post-login orchestration" effect are unchanged. - Changeset: `.changeset/30420-dev-admin-chip-password-off.md`, `@object-ui/console` patch. ## Tests `ui/apps/console/src/pages/auth/__tests__/LoginPage.dev-admin-hint.test.tsx`, two new cases: - seed + `emailPassword.enabled: false` (Google configured) → no `dev-admin-hint` row, no chip, read after the Google button appears; - seed + `emailPassword.enabled: true` → row and chip (positive control; the existing seed-only case covers the absent key). <details><summary>Readings</summary> - Target file at `e8c3c5f4`: Test Files 1 passed (1), Tests 12 passed (12), lock VERDICT command-exit 0. - Whole `apps/console/src/pages/auth/` at the merged head `f302e1af`: Test Files 28 passed (28), Tests 230 passed (230), lock VERDICT command-exit 0. - Ablation (fix committed first; `scripts/ablation-replace.mjs`, anchor `devSeedAdmin && authConfig?.emailPassword?.enabled !== false ? (` replaced by `devSeedAdmin ? (`, anchor x1 → x0, blob 3d2fbca → fa92222ba639): `× renders no row when the server turned email and password sign-in off`, Tests 1 failed / 11 passed. Restored: blob == HEAD (3d2fbca), `git diff HEAD` empty. - `pnpm --filter @object-ui/console run type-check`: exit 0. ESLint on both touched files: exit 0. </details> ## Acceptance notes - The whole row (label and chip) is hidden, not only the chip: the row exists to offer the seeded password account, which cannot sign in while password sign-in is off. ## Verification <details><summary>Gates</summary> - `node scripts/pm/dispatch-gates.mjs --repo objectstack-ai/objectstack --ran FILE`: 34 derived, 34 run, 0 NOT-MEASURED, 0 UNRUN, all with recorded exit codes, every one exit 0 (run at `e8c3c5f4`; the merge of `origin/main` into `f302e1af` brought no change to the three changed paths, and the derivation at `f302e1af` names the same 34). - Also run, exit 0: `pnpm --dir ui run check:spec-symbols`, `node scripts/check-sdui-manifest.mjs`, `pnpm check:changeset-fixed`, `pnpm --dir ui exec vitest run scripts/` (Test Files 170 passed / 2 skipped). - CI families: read from this PR's check-runs. </details> --- _Generated by [Claude Code](https://claude.ai/code/session_01L6bhgVfPeFZkN1FP93imKU)_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01L6bhgVfPeFZkN1FP93imKU Co-authored-by: Claude <noreply@anthropic.com>
1 parent 58085ff commit 35a8f08

3 files changed

Lines changed: 40 additions & 2 deletions

File tree

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
'@object-ui/console': patch
3+
---
4+
5+
fix(console): the sign-in page no longer offers "Sign in as dev admin" when email and password sign-in is off
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
Under `os dev`, the sign-in page drew the dev-seeded admin row whenever `/api/v1/auth/config` reported `devSeedAdmin`. Its chip signs in with email and password, so with that sign-in turned off the server refused it (`EMAIL_PASSWORD_DISABLED`) while the rest of the page correctly offered only the configured providers. The row is now drawn only when the same config does not report `emailPassword.enabled: false`, the answer the sign-in form already reads.

‎ui/apps/console/src/pages/auth/LoginPage.tsx‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,12 @@ export function LoginPage() {
396396
redirect={redirect}
397397
/>
398398
<InvitationLinkHint offer={signUpOffer} />
399-
{devSeedAdmin ? <DevAdminRow seed={devSeedAdmin} /> : null}
399+
{/* The row signs in with email and password: with that sign-in
400+
off (the same answer `LoginForm` reads) the server refuses
401+
it, so the row is not drawn. */}
402+
{devSeedAdmin && authConfig?.emailPassword?.enabled !== false ? (
403+
<DevAdminRow seed={devSeedAdmin} />
404+
) : null}
400405
</>
401406
)}
402407
</Card>

‎ui/apps/console/src/pages/auth/__tests__/LoginPage.dev-admin-hint.test.tsx‎

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
* through the same `signIn` the form submits with.
1818
*
1919
* Pinned here:
20-
* - the row renders only when the server reports `devSeedAdmin`;
20+
* - the row renders only when the server reports `devSeedAdmin`, and not when
21+
* it reports `emailPassword.enabled: false` (the chip's sign-in is refused);
2122
* - ⛔ the password never reaches the DOM — not as text, not in an attribute,
2223
* not in a hidden element — read off the whole document's markup;
2324
* - the chip hands the reported email and password to `signIn`, and a signed-in
@@ -149,6 +150,28 @@ describe('LoginPage — the dev-seeded admin row (objectui#12600)', () => {
149150
expect(document.documentElement.outerHTML).not.toContain(SEED_PASSWORD);
150151
});
151152

153+
it('renders no row when the server turned email and password sign-in off', async () => {
154+
renderLogin(
155+
createMockClient({
156+
...DEV_SEED,
157+
emailPassword: { enabled: false },
158+
socialProviders: [{ id: 'google', name: 'Google', enabled: true }],
159+
}),
160+
);
161+
162+
// The provider button appears once the config read has settled; the row must not.
163+
await screen.findByText(/Google/);
164+
expect(screen.queryByTestId('dev-admin-hint')).toBeNull();
165+
expect(screen.queryByTestId('dev-admin-signin')).toBeNull();
166+
});
167+
168+
it('renders the row and its chip when email and password sign-in is on', async () => {
169+
renderLogin(createMockClient({ ...DEV_SEED, emailPassword: { enabled: true } }));
170+
171+
await screen.findByTestId('dev-admin-hint');
172+
expect(screen.getByTestId('dev-admin-signin')).toBeTruthy();
173+
});
174+
152175
it('shows the email and no chip for a seed reported without a password', async () => {
153176
renderLogin(createMockClient({ devSeedAdmin: { email: SEED_EMAIL } }));
154177

0 commit comments

Comments
 (0)