v0.1.9 - B环境修复:auth认证+seek统计+数据库字段+短信配置
This commit is contained in:
parent
aa10dc4cc7
commit
bae5b6073a
|
|
@ -59,10 +59,14 @@ def decode_access_token(token: str) -> Optional[dict]:
|
|||
def get_current_user(
|
||||
credentials: Optional[HTTPAuthorizationCredentials] = Depends(security),
|
||||
db: Session = Depends(lambda: SessionLocal())
|
||||
) -> Optional[User]:
|
||||
"""获取当前用户(可返回None)"""
|
||||
) -> User:
|
||||
"""获取当前用户"""
|
||||
if not credentials:
|
||||
return None
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_401_UNAUTHORIZED,
|
||||
detail="未登录",
|
||||
headers={"WWW-Authenticate": "Bearer"},
|
||||
)
|
||||
|
||||
token = credentials.credentials
|
||||
payload = decode_access_token(token)
|
||||
|
|
@ -84,6 +88,10 @@ def get_current_user(
|
|||
|
||||
user = db.query(User).filter(User.f99_90_id == user_id).first()
|
||||
if not user:
|
||||
return None
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_401_UNAUTHORIZED,
|
||||
detail="用户不存在",
|
||||
headers={"WWW-Authenticate": "Bearer"},
|
||||
)
|
||||
|
||||
return user
|
||||
|
|
|
|||
|
|
@ -142,10 +142,9 @@ def get_seek_list(
|
|||
|
||||
@router.get("/stats")
|
||||
def get_seek_stats(
|
||||
current_user = Depends(get_current_user),
|
||||
db: Session = Depends(get_db)
|
||||
):
|
||||
"""获取寻配号统计"""
|
||||
"""获取寻配号统计(公开)"""
|
||||
total = db.query(SeekInfo).filter(SeekInfo.status == "active").count()
|
||||
matched = db.query(SeekInfo).filter(SeekInfo.is_matched == "true").count()
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ from fastapi import APIRouter, Depends, HTTPException, status, Query, Body
|
|||
from sqlalchemy.orm import Session
|
||||
from app.core.database import get_db
|
||||
from app.core.auth import get_current_user
|
||||
from app.models.models import User, Collection
|
||||
from app.models.models import User, Collection, Information
|
||||
from app.schemas.schemas import UserResponse, UserUpdate
|
||||
|
||||
router = APIRouter(prefix="/api", tags=["用户"])
|
||||
|
|
|
|||
|
|
@ -1,5 +1,26 @@
|
|||
# 版本更新记录
|
||||
|
||||
## v0.1.9 (2026-05-02)
|
||||
|
||||
### 后端更新
|
||||
- **auth.py**
|
||||
- 修复:get_current_user在未登录时返回None导致500错误,现在会返回401
|
||||
- 修复:用户不存在时返回None导致500错误,现在返回401
|
||||
- 修复:所有需要认证的接口现在会正确返回401
|
||||
|
||||
- **seek.py**
|
||||
- 修复:/api/seek/stats接口现在不需要登录(公开接口)
|
||||
|
||||
- **users.py**
|
||||
- 修复:添加Information模型导入
|
||||
|
||||
### 数据库更新
|
||||
- seek_info表添加network_matched_count字段
|
||||
|
||||
### 环境配置
|
||||
- B环境短信配置:AccessKey/SignName/TemplateCode更新
|
||||
- A环境短信配置:添加短信环境变量
|
||||
|
||||
## v0.1.8 (2026-05-01)
|
||||
|
||||
### 前端更新
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"version": "0.1.8",
|
||||
"updated": "2026-05-01",
|
||||
"version": "0.1.9",
|
||||
"updated": "2026-05-02",
|
||||
"modules": {
|
||||
"frontend": {
|
||||
"version": "0.1.8",
|
||||
|
|
@ -12,7 +12,7 @@
|
|||
}
|
||||
},
|
||||
"backend": {
|
||||
"version": "0.1.8",
|
||||
"version": "0.1.9",
|
||||
"routers": {
|
||||
"purchase": "0.2.0"
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in New Issue