Skip to content

Commit

Permalink
Merge pull request #142 from yanlong-li/master
Browse files Browse the repository at this point in the history
阻止按日期授权时剩余次数无限减少 & 阻止将管理员口令置空
  • Loading branch information
vastsa authored Mar 29, 2024
2 parents 7998607 + 7b37269 commit 77a0fed
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
4 changes: 4 additions & 0 deletions apps/admin/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ async def get_config():

@admin_api.patch('/config/update', dependencies=[Depends(admin_required)])
async def update_config(data: dict):
admin_token = data.get('admin_token')
if admin_token is None or admin_token == '':
return APIResponse(code=400, detail='管理员密码不能为空')

for k, v in data.items():
settings.__setattr__(k, v)
return APIResponse()
6 changes: 4 additions & 2 deletions apps/base/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ async def get_code_file(code: str, ip: str = Depends(error_ip_limit)):
return APIResponse(code=404, detail=file_code)
# 更新文件的使用次数和过期次数
file_code.used_count += 1
file_code.expired_count -= 1
if file_code.expired_count > 0:
file_code.expired_count -= 1
# 保存文件
await file_code.save()
# 返回文件响应
Expand All @@ -122,7 +123,8 @@ async def select_file(data: SelectFileModel, ip: str = Depends(error_ip_limit)):
return APIResponse(code=404, detail=file_code)
# 更新文件的使用次数和过期次数
file_code.used_count += 1
file_code.expired_count -= 1
if file_code.expired_count > 0:
file_code.expired_count -= 1
# 保存文件
await file_code.save()
# 返回API响应
Expand Down
6 changes: 5 additions & 1 deletion fcb-fronted/src/views/Admin/FileView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@
</template>
</el-table-column>
<el-table-column prop="used_count" :label="t('admin.fileView.used_count')" />
<el-table-column prop="expired_count" :label="t('admin.fileView.expired_count')" />
<el-table-column prop="expired_count" :label="t('admin.fileView.expired_count')">
<template #default="scope">
<span>{{ scope.row.expired_count > -1 ? scope.row.expired_count : '不限次数' }}</span>
</template>
</el-table-column>
<el-table-column prop="size" :label="t('admin.fileView.size')">
<template #default="scope">
<span>{{ Math.round(scope.row.size/1024/1024*100)/100 }}MB</span>
Expand Down

0 comments on commit 77a0fed

Please sign in to comment.