Skip to content

Commit

Permalink
Updated JWT errors class import
Browse files Browse the repository at this point in the history
  • Loading branch information
wu-clan committed Sep 13, 2024
1 parent f5b7de6 commit 9418447
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions backend/common/security/jwt.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from fastapi import Depends, Request
from fastapi.security import HTTPBearer
from fastapi.security.utils import get_authorization_scheme_param
from jose import jwt
from jose import ExpiredSignatureError, JWTError, jwt
from passlib.context import CryptContext
from sqlalchemy.ext.asyncio import AsyncSession

Expand Down Expand Up @@ -146,9 +146,9 @@ def jwt_decode(token: str) -> int:
user_id = int(payload.get('sub'))
if not user_id:
raise TokenError(msg='Token 无效')
except jwt.ExpiredSignatureError:
except ExpiredSignatureError:
raise TokenError(msg='Token 已过期')
except (jwt.JWTError, Exception):
except (JWTError, Exception):
raise TokenError(msg='Token 无效')
return user_id

Expand Down

0 comments on commit 9418447

Please sign in to comment.