docs: closeout wave landed — P8 batch-2 (server 12b8ffb 0.15.0 / crearte 7d5f338 0.21.0) + P3 reland (deploy 12f7c10 0.6.0 / server d627e12 0.16.0); ROADMAP P0-P8 all closed; spec pinned to reachable 409 semantics (wrapper 0.3.0)

This commit is contained in:
2026-10-01 05:07:56 +08:00
parent f1d8d9858b
commit d6e08e1d03
3 changed files with 14 additions and 6 deletions
@@ -47,7 +47,7 @@ ALTER TABLE users ADD COLUMN IF NOT EXISTS deleted_at timestamptz;
`AccountService{users UserStore, content ContentStore, objects storage.ObjectStorage}`:
- `DeleteAccountSelf(ctx, userID, password string) (AccountService 同包错误)`:`GetByIDForUpdate` → 不存在 ErrUnauthorized;`VerifyPassword` 失败 → `ErrInvalidCredentials`;`deleted_at != nil` → `ErrAccountDeleted`(幂等拒二次注销)。
- `DeleteAccountSelf(ctx, userID, password string) (Session同包错误)`:`GetByIDForUpdate` → 不存在 ErrUnauthorized;**先判 `deleted_at != nil` → `ErrAccountDeleted`(幂等拒二次注销;因墓碑 password_hash 已随机化,先验密码会误报 401 而非 410——审查后裁决 2026-10-01,实现照此)**;再 `VerifyPassword` 失败 → `ErrInvalidCredentials`。
- `DeleteAccountByEmail(ctx, email string)`(CLI 路径,免密码;不存在 → `ErrUserNotFound`)。
- 共享内核 `deleteAccountLocked`:
1. D-D 护栏:`role==admin && CountAdmins<=1` → `ErrLastAdmin`。
@@ -74,7 +74,7 @@ ALTER TABLE users ADD COLUMN IF NOT EXISTS deleted_at timestamptz;
### 3.5 前端(crearte)
- `auth/client.ts`:`deleteAccount(password: string): Promise<void>`(204 空体);`AuthErrorCode` 并集补 `'account_deleted'`(410→「该账号已注销」),`AUTH_ERROR_MESSAGES` 补条目。
- `AccountView.vue` 第四段「危险区:注销账号」:密码输入 + 「我已知晓作品将下架且不可恢复」勾选(两者齐备按钮才 enabled)+ 按钮「注销账号」;点击后 `busy` 锁;成功 → `session.invalidate()` → 跳首页 `router.push('/')`;失败 → `users-action-error` 风格 `role=alert` 行(文案走 `toUserMessage`/`AUTH_ERROR_MESSAGES`,last_admin 直出后端原文可接受)。noauth 下本页不可达(路由守卫),无需开关。
- `AccountView.vue` 第四段「危险区:注销账号」:密码输入 + 「我已知晓作品将下架且不可恢复」勾选(两者齐备按钮才 enabled)+ 按钮「注销账号」;点击后 `busy` 锁;成功 → `session.invalidate()` → 跳首页 `router.push('/')`;失败 → `users-action-error` 风格 `role=alert` 行(文案走 `toUserMessage`/`AUTH_ERROR_MESSAGES`)。**审查后实定(2026-10-01):auth client 的 `toErrorCode` 对未知码(含 last_admin)一律归一为 `internal` 且丢弃后端原文,故 AccountView 侧 409 展示通用「服务暂时不可用」文案——接受该现状(唯一 admin 自注销属边缘场景,AdminUsersView 侧 409 原文回显已由 P7 覆盖);原文「last_admin 直出后端原文可接受」仅适用于 AdminUsersView。** noauth 下本页不可达(路由守卫),无需开关。
- `AdminUsersView.vue`:`actionError` 改为按 `AdminApiError.code` 中文化:`validation`→「角色参数非法」、`not_found`→「用户不存在」、`internal`→「服务器内部错误,请稍后重试」、`last_admin`→保留后端原文透传(现有降级双要点文案已覆盖)、未知 code→后端 message 原样。
- e2e:`auth.spec`(按现有 mock/桩模式)加注销流:勾选+密码齐才可点、错误密码出文案、成功清会话回首页;`account-view` 相关单测(vitest)覆盖按钮禁用态与 204 后行为。