🔒️ Refactor migrate from python-jose to PyJWT (#1203)

This commit is contained in:
Esteban Maya
2024-05-15 10:48:57 -05:00
committed by GitHub
parent 13f4e844d3
commit ef1f64b8f5
5 changed files with 26 additions and 227 deletions

View File

@@ -5,8 +5,9 @@ from pathlib import Path
from typing import Any
import emails # type: ignore
import jwt
from jinja2 import Template
from jose import JWTError, jwt
from jwt.exceptions import InvalidTokenError
from app.core.config import settings
@@ -112,5 +113,5 @@ def verify_password_reset_token(token: str) -> str | None:
try:
decoded_token = jwt.decode(token, settings.SECRET_KEY, algorithms=["HS256"])
return str(decoded_token["sub"])
except JWTError:
except InvalidTokenError:
return None