Skip to content

Commit

Permalink
Refactor token refresh logic to use verify_token function for improve…
Browse files Browse the repository at this point in the history
…d clarity
  • Loading branch information
Vianpyro committed Nov 20, 2024
1 parent d2a431b commit a7eae1a
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions routes/authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from pymysql import MySQLError

from db import get_db_connection
from jwt_helper import generate_access_token, generate_refresh_token
from jwt_helper import generate_access_token, generate_refresh_token, verify_token

load_dotenv()

Expand Down Expand Up @@ -121,11 +121,7 @@ def refresh_token():
refresh_token = auth_header.split("Bearer ")[1]

try:
decoded = jwt.decode(
refresh_token,
os.getenv("SECRET_JWT_KEY", "SuperSecretKey"),
algorithms=["HS256"],
)
decoded = verify_token(refresh_token)
player_id = decoded["player_id"]

new_access_token = generate_access_token(player_id)
Expand Down

0 comments on commit a7eae1a

Please sign in to comment.