fix(admin): 后台未登录访问 Skills/MCP/Agent 报 Not authenticated\n\n- AdminLayout 增加登录+管理员守卫,无 token 或非 admin 跳 /login\n- api request() 处理 403 Not authenticated/需要管理员权限,清 token 跳登录\n- 根因:FastAPI HTTPBearer 无 token 返回 403 而非 401,前端未处理 403 跳转

This commit is contained in:
QihuAI Design committed 2026-07-17 20:46:05 +08:00
1 parent e2369b4915
commit f8d1c18927
2 files changed
+19

No files matched your search

@@ -191,6 +191,15 @@ const AdminLayout: React.FC = () => {
const location = useLocation();
// 后台必须登录且为管理员
useEffect(() => {
const token = localStorage.getItem('aiflow_token');
if (!token || !user || user.role !== 'admin') {
logout();
navigate('/login', { replace: true });
}
}, [user, logout, navigate]);
const navCrumb = (() => {
for (const g of adminNavGroups) {