update:限制管理员上传,最长天数配置

This commit is contained in:
lan
2022-12-14 09:55:04 +08:00
parent 47f1c9b74b
commit 6230a62dee
3 changed files with 13 additions and 9 deletions
+4 -6
View File
@@ -121,16 +121,14 @@ async def index(code: str, ip: str = Depends(error_ip_limit), s: AsyncSession =
}
@app.post('/share')
async def share(background_tasks: BackgroundTasks, pwd: str = Header(default=None), text: str = Form(default=None),
@app.post('/share', dependencies=[Depends(admin_required)], description='分享文件')
async def share(background_tasks: BackgroundTasks, text: str = Form(default=None),
style: str = Form(default='2'), value: int = Form(default=1), file: UploadFile = File(default=None),
ip: str = Depends(upload_ip_limit), s: AsyncSession = Depends(get_session)):
if not settings.ENABLE_UPLOAD and pwd != settings.ADMIN_PASSWORD:
raise HTTPException(status_code=403, detail="上传功能已关闭")
code = await get_code(s)
if style == '2':
if value > 7:
raise HTTPException(status_code=400, detail="最大有效天数为7")
if value > settings.MAX_DAYS:
raise HTTPException(status_code=400, detail=f"最大有效天数为{settings.MAX_DAYS}")
exp_time = datetime.datetime.now() + datetime.timedelta(days=value)
exp_count = -1
elif style == '1':