liuyun d793d34cfc
Some checks are pending
CI / backend (push) Waiting to run
CI / frontend (push) Waiting to run
feat(auth): 平台超管租户切换(子模块 + openspec change)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-10-12 00:02:52 +08:00

1.1 KiB
Raw Blame History

1. 后端 JWT super 标志

  • 1.1 issue() 增加可选 super 参数写入 access token 载荷
  • 1.2 checkUserActive 增加 super 处理:super token 在平台租户查用户

2. switch-tenant 接口

  • 2.1 auth/dto.ts 加 SwitchTenantDto;auth.service 加 switchTenant(校验平台超管 + 目标租户存在,签发 super token + 审计)
  • 2.2 auth.controller 加 POST /auth/switch-tenant
  • 2.3 jwt-auth.guard 把 super 传给 checkUserActive 并写入 request.user

3. isSuper 解析

  • 3.1 新增 isPlatformSuperAdmin(userId) 辅助(查平台租户 user_role)
  • 3.2 resolveAuth/buildContext/getMenus 的 isSuper 判定加平台租户检查

4. 前端切换入口

  • 4.1 api/auth.ts 加 switchTenant;auth store 加切换动作(换 token)
  • 4.2 ty-header 顶栏「切换租户」下拉(仅 super 显示),切换后重置菜单/字典/权限/页签并刷新

5. 验证

  • 5.1 后端 build + 单测 + e2e 通过
  • 5.2 前端 type-check 通过
  • 5.3 冒烟:超管切到 demo → 列出 demo 用户 → 切回 touyun