diff options
author | Parker <contact@pkrm.dev> | 2024-11-05 20:36:09 -0600 |
---|---|---|
committer | Parker <contact@pkrm.dev> | 2024-11-05 20:36:09 -0600 |
commit | e944df3d7d431b5bd88c2c235501a355ea1ba6ab (patch) | |
tree | 283a28cb77f2439d20ba00869de15cf65c2c450a /app/routes/auth_routes.py | |
parent | 6f7e810916fd2de39d451886bbe18167e1784315 (diff) |
Fix auth and organization/standards
Diffstat (limited to 'app/routes/auth_routes.py')
-rw-r--r-- | app/routes/auth_routes.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/app/routes/auth_routes.py b/app/routes/auth_routes.py index a28ec63..4d1c25e 100644 --- a/app/routes/auth_routes.py +++ b/app/routes/auth_routes.py @@ -26,7 +26,7 @@ async def login_for_access_token( Return an access token for the user, if the given authentication details are correct """ user = authenticate_user(db, form_data.username, form_data.password) - print(user) + if not user: raise HTTPException( status_code=status.HTTP_401_UNAUTHORIZED, @@ -35,14 +35,14 @@ async def login_for_access_token( ) access_token_expires = timedelta(minutes=15) access_token = create_access_token( - data={"sub": user.id, "refresh": False}, + data={"sub": user.id, "username": user.username, "refresh": False}, expires_delta=access_token_expires, ) # Create a refresh token - just an access token with a longer expiry # and more restrictions ("refresh" is True) refresh_token_expires = timedelta(days=1) refresh_token = create_access_token( - data={"sub": user.id, "refresh": True}, + data={"sub": user.id, "username": user.username, "refresh": True}, expires_delta=refresh_token_expires, ) # response = JSONResponse(content={"success": True}) |