diff --git a/routes/auth.py b/routes/auth.py index 393542a..bbd62c1 100644 --- a/routes/auth.py +++ b/routes/auth.py @@ -45,9 +45,11 @@ async def get_user(token: str = Depends(oauth2_scheme), try: payload = jwt.decode(token, SECRET_KEY) token_data = TokenData(**payload) - except Exception: + except Exception as e: + print(e) raise credentials_exception user = await db.get_user(db_session, token_data.username) + print(user) if user is None: raise credentials_exception return user @@ -59,7 +61,7 @@ def create_token(user: db.User): expire = datetime.now(timezone.utc) + access_token_expires to_encode = { "id": user.id, - "name": user.name, + "username": user.name, "email": user.email, "expire": str(expire) } diff --git a/routes/games.py b/routes/games.py index fde1619..a8beb64 100644 --- a/routes/games.py +++ b/routes/games.py @@ -51,6 +51,7 @@ async def delete_game(game_id: int, user: db.User = Depends(get_user), db_session: AsyncSession = Depends(db.get_session)): game_db = await db.get_game(db_session, game_id) + print(game_db) if (game_db is None): raise HTTPException(status.HTTP_404_NOT_FOUND, detail=f"Game with id={game_id} not found")