火山引擎SMS API|celery容灾优化|生成模型引擎积分列表API

This commit is contained in:
2026-06-04 16:28:59 +08:00
parent 450e509b1a
commit 8d43d5871c
25 changed files with 1936 additions and 302 deletions
+18 -4
View File
@@ -1,11 +1,11 @@
from fastapi import Depends, HTTPException, status
from fastapi.security import HTTPAuthorizationCredentials, HTTPBearer
from sqlalchemy import select
from sqlalchemy.ext.asyncio import AsyncSession
from app.models.base import async_session
from app.models.user import User
from app.services.auth import decode_access_token
from sqlalchemy import select
from app.services.auth import decode_access_token, user_must_set_password
security = HTTPBearer(auto_error=False)
@@ -22,7 +22,7 @@ async def get_db():
await session.close()
async def get_current_user(
async def get_current_user_allow_password_pending(
credentials: HTTPAuthorizationCredentials | None = Depends(security),
db: AsyncSession = Depends(get_db),
) -> User:
@@ -56,8 +56,22 @@ async def get_current_user(
return user
async def get_current_user(
current_user: User = Depends(get_current_user_allow_password_pending),
) -> User:
if user_must_set_password(current_user):
raise HTTPException(
status_code=status.HTTP_403_FORBIDDEN,
detail={
"code": "PASSWORD_REQUIRED",
"message": "请先设置登录密码",
},
)
return current_user
async def get_admin_user(
current_user: User = Depends(get_current_user),
current_user: User = Depends(get_current_user_allow_password_pending),
) -> User:
if not current_user.is_admin or current_user.user_type != "admin":
raise HTTPException(