pytest 1.7

This commit is contained in:
2025-10-12 18:59:42 +03:00
parent c015a25c81
commit 903cb7c930
2 changed files with 25 additions and 2 deletions

View File

@@ -1,4 +1,4 @@
from datetime import datetime, timedelta #jwt
from datetime import datetime, timedelta, timezone #jwt
from jose import JWTError, jwt
from fastapi import HTTPException, Depends, status
from fastapi.security import OAuth2PasswordBearer
@@ -17,7 +17,7 @@ class Token():
@staticmethod
async def create_token(data: dict, expires_delta: timedelta | None = None):
to_encode = data.copy()
expire = datetime.utcnow() + (expires_delta or timedelta(minutes=15))
expire = datetime.now(timezone.utc) + (expires_delta or timedelta(minutes=15))
to_encode.update({"exp": expire})
encoded_jwt = jwt.encode(to_encode, SECRET_KEY, algorithm=ALGORITHM)
return encoded_jwt