fix: 修复后端代码违规并更新协议文档
- 修复 notifications 模块 datetime.now() 缺少时区问题 - 用 ApiProblemError 替换 BaseService 中的 HTTPException - 更新协议文档:添加错误码、繁体字段、邀请相关协议 - 升级 Docker 镜像版本
This commit is contained in:
@@ -2,9 +2,8 @@ from __future__ import annotations
|
||||
|
||||
from uuid import UUID
|
||||
|
||||
from fastapi import HTTPException
|
||||
|
||||
from core.auth.models import CurrentUser
|
||||
from core.http.errors import ApiProblemError, problem_payload
|
||||
|
||||
|
||||
class BaseService:
|
||||
@@ -15,7 +14,10 @@ class BaseService:
|
||||
|
||||
def require_current_user(self) -> CurrentUser:
|
||||
if self._current_user is None:
|
||||
raise HTTPException(status_code=401, detail="Unauthorized")
|
||||
raise ApiProblemError(
|
||||
status_code=401,
|
||||
detail=problem_payload(code="AUTH_UNAUTHORIZED", detail="Unauthorized"),
|
||||
)
|
||||
return self._current_user
|
||||
|
||||
def require_user_id(self) -> UUID:
|
||||
|
||||
Reference in New Issue
Block a user