Skip to content

Commit df03b55

Browse files
committed
Fix token data issued_at and expires_at validation
1 parent e742590 commit df03b55

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

  • {{cookiecutter.project_name}}/template_minimal/app/api

{{cookiecutter.project_name}}/template_minimal/app/api/deps.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ async def get_current_user(
4141
detail="Could not validate credentials, cannot use refresh token",
4242
)
4343
now = int(time.time())
44-
if not now >= token_data.issued_at and now <= token_data.expires_at:
44+
if now < token_data.issued_at or now > token_data.expires_at:
4545
raise HTTPException(
4646
status_code=status.HTTP_403_FORBIDDEN,
4747
detail="Could not validate credentials, token expired or not yet valid",

{{cookiecutter.project_name}}/template_minimal/app/api/endpoints/auth.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ async def refresh_token(
6262
detail="Could not validate credentials, cannot use access token",
6363
)
6464
now = int(time.time())
65-
if not now >= token_data.issued_at and now <= token_data.expires_at:
65+
if now < token_data.issued_at or now > token_data.expires_at:
6666
raise HTTPException(
6767
status_code=status.HTTP_403_FORBIDDEN,
6868
detail="Could not validate credentials, token expired or not yet valid",

0 commit comments

Comments
 (0)