Align admin user creation with the pending-account contract #94

Merged
weichen merged 2 commits from fix/admin-user-create-contract into main 2026-10-16 07:48:50 +00:00
Owner

目标

修复管理员建号 UI 400(json: unknown field "name"):backend 8dfc223 将 POST /api/admin/users 改为严格 {owner, profile} 解码,且登录 Key 签发端点替换为 410,前端未跟进。

变更

  • createAdminUser 改发 {owner, profile:{name}}(严格契约,无多余字段)
  • 移除初始密码输入、随机密码按钮与管理员勾选(新契约下 HTTP 建号不能设密码/授权限)
  • 建号提示改为待初始化 + 服务器 user initialize-account 发放激活 Key 指引
  • 移除已 410 的「生成登录 Key」入口及其死代码;list/revoke api 定义保留供恢复提案增量复用
  • 删除唯一消费者丢失的 src/passwords.ts

验证

  • npm run build(tsc -b + vite)通过;npm test 34 文件/293 用例全过;knip 与同 pin 基线逐项一致(SELF,任务卡 evidence)
  • GATE:Dev 组合 CI 按 pin 精确检出(合入顺序 Dev CI 绿 → 本 PR → Dev pin bump)

任务卡

Dev 仓 fix/admin-user-create-contract(R0 9edb011)

## 目标 修复管理员建号 UI 400(`json: unknown field "name"`):backend 8dfc223 将 `POST /api/admin/users` 改为严格 `{owner, profile}` 解码,且登录 Key 签发端点替换为 410,前端未跟进。 ## 变更 - `createAdminUser` 改发 `{owner, profile:{name}}`(严格契约,无多余字段) - 移除初始密码输入、随机密码按钮与管理员勾选(新契约下 HTTP 建号不能设密码/授权限) - 建号提示改为待初始化 + 服务器 `user initialize-account` 发放激活 Key 指引 - 移除已 410 的「生成登录 Key」入口及其死代码;list/revoke api 定义保留供恢复提案增量复用 - 删除唯一消费者丢失的 `src/passwords.ts` ## 验证 - `npm run build`(tsc -b + vite)通过;`npm test` 34 文件/293 用例全过;knip 与同 pin 基线逐项一致(SELF,任务卡 evidence) - GATE:Dev 组合 CI 按 pin 精确检出(合入顺序 Dev CI 绿 → 本 PR → Dev pin bump) ## 任务卡 Dev 仓 fix/admin-user-create-contract(R0 9edb011)
weichen added 1 commit 2026-10-16 06:43:07 +00:00
Why: backend 8dfc223 replaced POST /api/admin/users with strict
{owner, profile} decoding and returned 410 for login-key issuing, so the
UI create form failed with 400 unknown field name. Creation now sends
{owner, profile:{name}} only; password input, admin checkbox and the
login-key issue entry are removed; notice points to the local CLI
initialize-account flow. passwords.ts lost its only consumer.
Evidence: npm run build + npm test (34 files/293 passed) + knip identical
to baseline on the task worktree (SELF).
Impact: UsersPanel and api client only; no style/token changes.
Refs: backend 8dfc223, b9c0a34
weichen added 1 commit 2026-10-16 07:17:05 +00:00
Why: independent review flagged the issue client still targeting the 410
endpoint and a hint sentence ending with a period.
Evidence: npm run build + npm test re-run on the fix (SELF).
Impact: api client surface only.
Refs: review brief /tmp/review-brief-admin-user-contract.md
weichen merged commit 46e99fedbb into main 2026-10-16 07:48:50 +00:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: weichen/Agent-System-Frontend#94