Work on game form

This commit is contained in:
2024-05-26 20:39:59 +04:00
parent 2f8d1e5f47
commit fe424182df
2 changed files with 5 additions and 2 deletions

View File

@@ -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)
}