Skip to content

Commit

Permalink
fix: Change in session class
Browse files Browse the repository at this point in the history
  • Loading branch information
KShivendu committed Sep 1, 2023
1 parent 1c7ffb8 commit 372491d
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions supertokens_python/recipe/session/with_jwt/session_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,16 @@ async def update_access_token_payload(
if decoded_payload is None or decoded_payload.get("exp") is None:
raise Exception("Error reading JWT from session")

jwt_expiry = 1
if "exp" in decoded_payload:
exp = decoded_payload["exp"]
if exp > current_time_in_seconds:
# it can come here if someone calls this function well after
# the access token and the jwt payload have expired. In this case,
# we still want the jwt payload to update, but the resulting JWT should
# not be alive for too long (since it's expired already). So we set it to
# 1 second lifetime.
jwt_expiry = exp - current_time_in_seconds
jwt_expiry = decoded_payload.get("exp", 0) - current_time_in_seconds
# pylint: disable=consider-using-max-builtin
if jwt_expiry < 1:
# it can come here if someone calls this function well after
# the access token and the jwt payload have expired. In this case,
# we still want the jwt payload to update, but the resulting JWT should
# not be alive for too long (since it's expired already). So we set it to
# 1 second lifetime.
jwt_expiry = 1
# pylint: enable=consider-using-max-builtin

new_access_token_payload = await add_jwt_to_access_token_payload(
access_token_payload=new_access_token_payload,
Expand Down

0 comments on commit 372491d

Please sign in to comment.