修复因无JWT令牌而无法正确启动 Findreve
This commit is contained in:
5
main.py
5
main.py
@@ -1,3 +1,8 @@
|
|||||||
|
# 初始化数据库
|
||||||
|
import asyncio
|
||||||
|
from model.database import Database
|
||||||
|
asyncio.run(Database().init_db())
|
||||||
|
|
||||||
# 导入库
|
# 导入库
|
||||||
from app import app
|
from app import app
|
||||||
from fastapi.staticfiles import StaticFiles
|
from fastapi.staticfiles import StaticFiles
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ from typing import Literal, Optional
|
|||||||
|
|
||||||
class DefaultResponse(BaseModel):
|
class DefaultResponse(BaseModel):
|
||||||
code: int = 0
|
code: int = 0
|
||||||
data: dict | list | None = None
|
data: dict | list | bool | None = None
|
||||||
msg: str = ""
|
msg: str = ""
|
||||||
|
|
||||||
class ObjectData(BaseModel):
|
class ObjectData(BaseModel):
|
||||||
|
|||||||
BIN
requirements.txt
BIN
requirements.txt
Binary file not shown.
@@ -30,16 +30,14 @@ Router = APIRouter(
|
|||||||
response_model=DefaultResponse,
|
response_model=DefaultResponse,
|
||||||
response_description='当前为管理员'
|
response_description='当前为管理员'
|
||||||
)
|
)
|
||||||
async def verity_admin(
|
async def verity_admin() -> DefaultResponse:
|
||||||
is_admin: Annotated[str, Depends(is_admin)]
|
|
||||||
) -> Literal[True]:
|
|
||||||
'''
|
'''
|
||||||
使用 API 验证是否为管理员。
|
使用 API 验证是否为管理员。
|
||||||
|
|
||||||
- 若为管理员,返回 `True`
|
- 若为管理员,返回 `True`
|
||||||
- 若不是管理员,抛出 `401` 错误
|
- 若不是管理员,抛出 `401` 错误
|
||||||
'''
|
'''
|
||||||
return is_admin
|
return DefaultResponse(data=True)
|
||||||
|
|
||||||
@Router.get(
|
@Router.get(
|
||||||
path='/items',
|
path='/items',
|
||||||
|
|||||||
Reference in New Issue
Block a user