aboutsummaryrefslogtreecommitdiff
path: root/api/main.py
diff options
context:
space:
mode:
authorParker <contact@pkrm.dev>2024-11-04 21:14:18 -0600
committerParker <contact@pkrm.dev>2024-11-04 21:14:18 -0600
commit5a0777033f6733c33fbd6119ade812e0c749be44 (patch)
tree22abb7d688f5551937ccc71c173e18b444e55eae /api/main.py
parentd4280d1fda2f4809274793e7bd49f484f57a883e (diff)
Work on refresh tokens
Diffstat (limited to 'api/main.py')
-rw-r--r--api/main.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/api/main.py b/api/main.py
index 54d9f5e..fbe8805 100644
--- a/api/main.py
+++ b/api/main.py
@@ -9,7 +9,7 @@ from fastapi.security import OAuth2PasswordRequestForm, OAuth2PasswordBearer
from api.util.authentication import (
authenticate_user,
create_access_token,
- get_current_user,
+ refresh_get_current_user,
)
from api.routes.links_route import router as links_router
from api.util.db_dependency import get_db
@@ -75,10 +75,10 @@ async def login_for_access_token(
)
# Create a refresh token - just an access token with a longer expiry
# and more restrictions ("refresh" is True)
- refresh_token_expire = timedelta(days=1)
+ refresh_token_expires = timedelta(days=1)
refresh_token = create_access_token(
data={"sub": user.username, "refresh": True},
- expire_delta=refresh_token_expire,
+ expires_delta=refresh_token_expires,
)
return Token(
access_token=access_token,
@@ -91,8 +91,8 @@ async def login_for_access_token(
# Part of that is token refresh, so we must implement it ourselves
@app.post("/refresh")
async def refresh_access_token(
- current_user: Annotated[User, Depends(get_current_user, refresh=True)],
-):
+ current_user: Annotated[User, Depends(refresh_get_current_user)],
+) -> Token:
"""
Return a new access token if the refresh token is valid
"""