Files
Agent-System/.doc/audit/2026-09-13-auth-useraccount-snake-case-mapping.md
T
weichenandCursor 9345109dca docs(ops): archive completed document-revision session files
Move done DOCREV short-terms, checklists, and handoffs into archive/ops and retarget relative links after Round20 close-out.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-14 00:27:18 +00:00

1.7 KiB
Raw Blame History

title, status, created, updated, severity
title status created updated severity
Auth UserAccount snake_case 契约漏映射导致管理员入口隐藏 done 2026-09-13 2026-09-13 high

Auth UserAccount snake_case 契约漏映射导致管理员入口隐藏

现象

真实浏览器 UI-00(Antigravity):管理员登录后左侧「系统管理」入口不可见,无法开通 A/B 账号。控制台侧 currentUser.roleId 为 undefined(服务端实际返回 role_id: "role-admin")。

根因分析

  • Go auth.UserAccount JSON 标签为 snake_case:role_id / employee_id / must_change_password / created_at / updated_at。
  • 前端 AuthClient 将 login / me / admin users 响应直接当作 camelCase UserAccount 使用,未在 API 边界映射。
  • 既有单测使用内存 auth.local 或驼峰假响应,未覆盖真实 wire 契约,故漏检。
  • BootstrapAdminFromConfig 对已存在非 admin 账号调用 UpdateUserRole 时静默忽略错误(_, _ =),可能留下非 role-admin 管理员配置账号。

严重度

high

关联整改

证据

  • UI-00 实战:管理员登录后无系统管理入口(roleId undefined)
  • internal/auth/models.go UserAccount json tags
  • web/src/api/auth.ts 原直接 resp.json() 赋给 UserAccount

开放问题

  • 无(映射层 + bootstrap 错误上浮已落地;占槽后需重跑 UI-00 验证管理员入口)