mirror of
https://github.com/EstrellaXD/Auto_Bangumi.git
synced 2026-04-27 12:00:32 +08:00
fix: leak of response model.
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
import logging
|
||||
|
||||
from fastapi import APIRouter, Depends, HTTPException, status
|
||||
from fastapi import APIRouter, Depends
|
||||
from fastapi.responses import JSONResponse
|
||||
|
||||
from module.conf import settings
|
||||
from module.models import Config
|
||||
from module.models import Config, APIResponse
|
||||
from module.security.api import get_current_user, UNAUTHORIZED
|
||||
|
||||
router = APIRouter(prefix="/config", tags=["config"])
|
||||
@@ -17,7 +18,7 @@ async def get_config(current_user=Depends(get_current_user)):
|
||||
return settings
|
||||
|
||||
|
||||
@router.patch("/update")
|
||||
@router.patch("/update", response_model=APIResponse)
|
||||
async def update_config(config: Config, current_user=Depends(get_current_user)):
|
||||
if not current_user:
|
||||
raise UNAUTHORIZED
|
||||
@@ -26,7 +27,13 @@ async def update_config(config: Config, current_user=Depends(get_current_user)):
|
||||
settings.load()
|
||||
# update_rss()
|
||||
logger.info("Config updated")
|
||||
return {"message": "Success"}
|
||||
return JSONResponse(
|
||||
status_code=200,
|
||||
content={"msg_en": "Update config successfully.", "msg_zh": "更新配置成功。"}
|
||||
)
|
||||
except Exception as e:
|
||||
logger.warning(e)
|
||||
return {"message": "Failed to update config"}
|
||||
return JSONResponse(
|
||||
status_code=406,
|
||||
content={"msg_en": "Update config failed.", "msg_zh": "更新配置失败。"}
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user