Skip to content

Commit 172bfd9

Browse files
sameeramintiangolo
andauthored
♻️ Refactored code to use encryption algorithm name from settings for consistency (#1160)
Co-authored-by: Sebastián Ramírez <[email protected]>
1 parent 79883c8 commit 172bfd9

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

backend/app/utils.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from jinja2 import Template
1010
from jwt.exceptions import InvalidTokenError
1111

12+
from app.core import security
1213
from app.core.config import settings
1314

1415
logging.basicConfig(level=logging.INFO)
@@ -107,14 +108,16 @@ def generate_password_reset_token(email: str) -> str:
107108
encoded_jwt = jwt.encode(
108109
{"exp": exp, "nbf": now, "sub": email},
109110
settings.SECRET_KEY,
110-
algorithm="HS256",
111+
algorithm=security.ALGORITHM,
111112
)
112113
return encoded_jwt
113114

114115

115116
def verify_password_reset_token(token: str) -> str | None:
116117
try:
117-
decoded_token = jwt.decode(token, settings.SECRET_KEY, algorithms=["HS256"])
118+
decoded_token = jwt.decode(
119+
token, settings.SECRET_KEY, algorithms=[security.ALGORITHM]
120+
)
118121
return str(decoded_token["sub"])
119122
except InvalidTokenError:
120123
return None

0 commit comments

Comments
 (0)