后端bug修复
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
# ===========================================
|
||||
# 班级操行分管理系统 - 后端服务
|
||||
# 班级操行分管理系统 - 权限验证中间件
|
||||
#
|
||||
# 开发者: Canglan
|
||||
# 联系方式: admin@sea-studio.top
|
||||
@@ -10,7 +10,7 @@
|
||||
# ===========================================
|
||||
|
||||
from fastapi import Request, HTTPException
|
||||
from typing import List, Optional, Callable
|
||||
from typing import List, Optional, Callable, Dict, Any
|
||||
from functools import wraps
|
||||
|
||||
from utils.response import forbidden_response
|
||||
@@ -20,6 +20,22 @@ from utils.logger import get_logger
|
||||
logger = get_logger(__name__)
|
||||
|
||||
|
||||
async def get_current_user(request: Request) -> Dict[str, Any]:
|
||||
"""获取当前登录用户信息"""
|
||||
return {
|
||||
"user_id": getattr(request.state, 'user_id', None),
|
||||
"username": getattr(request.state, 'username', None),
|
||||
"user_type": getattr(request.state, 'user_type', None),
|
||||
"student_id": getattr(request.state, 'student_id', None),
|
||||
"role": getattr(request.state, 'role', None)
|
||||
}
|
||||
|
||||
|
||||
async def get_current_user_id(request: Request) -> int:
|
||||
"""获取当前用户ID"""
|
||||
return getattr(request.state, 'user_id', None)
|
||||
|
||||
|
||||
class PermissionChecker:
|
||||
"""权限检查器"""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user