Skip to content

Commit d35c84c

Browse files
author
Lan
committed
fix: 游客上传
1 parent 0d1aa81 commit d35c84c

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

apps/admin/dependencies.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,13 @@ async def admin_required(authorization: str = Header(default=None), request: Req
6868
验证管理员权限
6969
"""
7070
try:
71-
if not authorization or not authorization.startswith('Bearer '):
72-
raise ValueError("缺少Bearer token")
73-
74-
token = authorization.split(' ')[1]
75-
payload = verify_token(token)
76-
is_admin = payload.get("is_admin", False)
77-
71+
if not authorization or not authorization.startswith("Bearer "):
72+
is_admin = False
73+
else:
74+
token = authorization.split(" ")[1]
75+
payload = verify_token(token)
76+
is_admin = payload.get("is_admin", False)
77+
7878
if request.url.path.startswith('/share/'):
7979
if not settings.openUpload and not is_admin:
8080
raise HTTPException(status_code=403, detail='本站未开启游客上传,如需上传请先登录后台')

0 commit comments

Comments
 (0)