Skip to content

Commit

Permalink
Making the timeout configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Gomez-Gonzalez committed Oct 4, 2024
1 parent d063e3b commit 88623e7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ screenshots from Chrome and add them to the backend.
JWT_SECRET="some random secret key"
JWT_ALGORITHM="HS256"
DB_URL="sqlite:///database.db"
TOKEN_TIMEOUT=30
```

5. Run the app:
Expand Down
4 changes: 3 additions & 1 deletion app/api.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""API methods."""

import os
from datetime import timedelta, datetime
from typing import Annotated

Expand Down Expand Up @@ -62,7 +63,8 @@ async def login(
if not db_user:
raise HTTPException(
status_code=400, detail="Incorrect username or password")
token = auth_handler.create_access_token(db_user, timedelta(minutes=30))
time_out = int(os.getenv("TOKEN_TIMEOUT")) or 30
token = auth_handler.create_access_token(db_user, timedelta(minutes=time_out))
return model.Token(access_token=token, token_type="bearer")


Expand Down

0 comments on commit 88623e7

Please sign in to comment.