feat: 平台管理员端 — SUPER_ADMIN 角色 + 企业租户管理 + 用户管理 + 数据总览
This commit is contained in:
@@ -2,8 +2,8 @@ import { Request, Response, NextFunction } from 'express'
|
||||
import { verifyAccessToken } from '../lib/jwt'
|
||||
|
||||
export interface AuthRequest extends Request {
|
||||
user?: { id: string; orgId: string; role: string }
|
||||
orgId?: string
|
||||
user?: { id: string; orgId: string | null; role: string }
|
||||
orgId?: string | null
|
||||
}
|
||||
|
||||
export function authMiddleware(req: AuthRequest, res: Response, next: NextFunction) {
|
||||
@@ -26,3 +26,13 @@ export function orgFilterMiddleware(req: AuthRequest, _res: Response, next: Next
|
||||
}
|
||||
next()
|
||||
}
|
||||
|
||||
/**
|
||||
* 平台管理员鉴权中间件,仅允许 SUPER_ADMIN 角色通过
|
||||
*/
|
||||
export function platformAdminMiddleware(req: AuthRequest, res: Response, next: NextFunction) {
|
||||
if (!req.user || req.user.role !== 'SUPER_ADMIN') {
|
||||
return res.status(403).json({ success: false, error: { code: 'FORBIDDEN', message: '需要平台管理员权限' } })
|
||||
}
|
||||
next()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user