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

25 lines
1.3 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.

## Why
平台超级管理员(`super_admin`,位于 `touyun` 租户)登录后只能看到自己所在租户的业务数据,无法切入其他租户(如 `demo`)管理其用户/角色——当前多租户隔离把业务数据锁死在登录租户内,但平台超管理应有「切入任意租户」的能力。
## What Changes
- JWT 增加 `super` 标志(仅切换接口签发);`sub` 始终是平台超管真实 userId,`tenantCode` 随切换变化。
- 新增 `POST /auth/switch-tenant`:平台超管切入目标租户,签发新 token。
- `isSuper` 判定改为「当前租户含 super_admin 或 平台租户(touyun)含 super_admin」,切换后仍按超管绕过权限、数据按目标租户过滤。
- 前端顶栏为超管提供「切换租户」入口。
## Capabilities
### Modified Capabilities
- `backend/auth`: 平台超管跨租户切换(super 标志 + 切换接口 + isSuper 解析)。
- `shared/api-contract`: 新增 `POST /auth/switch-tenant`。
- `frontend/AD/layout`: 顶栏租户切换入口。
## Impact
- **后端**:`auth`(JWT super 标志、switch-tenant 接口、`checkUserActive`/`resolveAuth`/`buildContext`/`getMenus` 的 isSuper 解析)。
- **前端**:顶栏切换下拉、auth store 更新 token、切换后重置菜单/字典/权限缓存。
- 无数据变更。