Skip to content

Commit 33d74b2

Browse files
committed
♻️ Refactored code to use encryption algorithm name from settings for consistency
1 parent 98bd7e6 commit 33d74b2

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

Diff for: backend/app/utils.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from jinja2 import Template
99
from jose import JWTError, jwt
1010

11+
from app.core import security
1112
from app.core.config import settings
1213

1314

@@ -103,14 +104,16 @@ def generate_password_reset_token(email: str) -> str:
103104
encoded_jwt = jwt.encode(
104105
{"exp": exp, "nbf": now, "sub": email},
105106
settings.SECRET_KEY,
106-
algorithm="HS256",
107+
algorithm=security.ALGORITHM,
107108
)
108109
return encoded_jwt
109110

110111

111112
def verify_password_reset_token(token: str) -> str | None:
112113
try:
113-
decoded_token = jwt.decode(token, settings.SECRET_KEY, algorithms=["HS256"])
114+
decoded_token = jwt.decode(
115+
token, settings.SECRET_KEY, algorithms=[security.ALGORITHM]
116+
)
114117
return str(decoded_token["sub"])
115118
except JWTError:
116119
return None

0 commit comments

Comments
 (0)