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

27 lines
1.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

## 1. 后端 JWT super 标志
- [x] 1.1 `issue()` 增加可选 `super` 参数写入 access token 载荷
- [x] 1.2 `checkUserActive` 增加 super 处理:super token 在平台租户查用户
## 2. switch-tenant 接口
- [x] 2.1 `auth/dto.ts` 加 `SwitchTenantDto`;`auth.service` 加 `switchTenant`(校验平台超管 + 目标租户存在,签发 super token + 审计)
- [x] 2.2 `auth.controller` 加 `POST /auth/switch-tenant`
- [x] 2.3 `jwt-auth.guard` 把 `super` 传给 `checkUserActive` 并写入 `request.user`
## 3. isSuper 解析
- [x] 3.1 新增 `isPlatformSuperAdmin(userId)` 辅助(查平台租户 user_role)
- [x] 3.2 `resolveAuth`/`buildContext`/`getMenus` 的 isSuper 判定加平台租户检查
## 4. 前端切换入口
- [x] 4.1 `api/auth.ts` 加 `switchTenant`;auth store 加切换动作(换 token)
- [x] 4.2 `ty-header` 顶栏「切换租户」下拉(仅 super 显示),切换后重置菜单/字典/权限/页签并刷新
## 5. 验证
- [x] 5.1 后端 build + 单测 + e2e 通过
- [x] 5.2 前端 type-check 通过
- [x] 5.3 冒烟:超管切到 demo → 列出 demo 用户 → 切回 touyun