Update codebase and add coverage report

Removed an old run configuration, added a new coverage XML report, and updated multiple source files including main.py, middleware, models, routers, services, tests, and utility modules. Also updated pyproject.toml and the lock file. These changes likely include code improvements, test coverage updates, and dependency adjustments.
This commit is contained in:
2025-12-26 14:56:08 +08:00
parent a716b2b0db
commit 54784eea3b
17 changed files with 4583 additions and 271 deletions

View File

@@ -1,4 +1,5 @@
from typing import Annotated
from uuid import UUID
from fastapi import Depends
import jwt
@@ -17,13 +18,15 @@ async def auth_required(
"""
try:
payload = jwt.decode(token, JWT.SECRET_KEY, algorithms=["HS256"])
username = payload.get("sub")
user_id = payload.get("sub")
if username is None:
if user_id is None:
http_exceptions.raise_unauthorized("账号或密码错误")
user_id = UUID(user_id)
# 从数据库获取用户信息
user = await User.get(session, User.username == username)
user = await User.get(session, User.id == user_id)
if not user:
http_exceptions.raise_unauthorized("账号或密码错误")