Marketplace tests update
This commit is contained in:
@@ -9,7 +9,7 @@ This module provides classes and functions for:
|
||||
|
||||
import logging
|
||||
import os
|
||||
from datetime import datetime, timedelta
|
||||
from datetime import datetime, timedelta, timezone
|
||||
from typing import Any, Dict, Optional
|
||||
|
||||
from fastapi import HTTPException
|
||||
@@ -71,7 +71,7 @@ class AuthManager:
|
||||
def create_access_token(self, user: User) -> Dict[str, Any]:
|
||||
"""Create JWT access token for user."""
|
||||
expires_delta = timedelta(minutes=self.token_expire_minutes)
|
||||
expire = datetime.utcnow() + expires_delta
|
||||
expire = datetime.now(timezone.utc) + expires_delta
|
||||
|
||||
payload = {
|
||||
"sub": str(user.id),
|
||||
@@ -79,7 +79,7 @@ class AuthManager:
|
||||
"email": user.email,
|
||||
"role": user.role,
|
||||
"exp": expire,
|
||||
"iat": datetime.utcnow(),
|
||||
"iat": datetime.now(timezone.utc),
|
||||
}
|
||||
|
||||
token = jwt.encode(payload, self.secret_key, algorithm=self.algorithm)
|
||||
@@ -100,7 +100,7 @@ class AuthManager:
|
||||
if exp is None:
|
||||
raise InvalidTokenException("Token missing expiration")
|
||||
|
||||
if datetime.utcnow() > datetime.fromtimestamp(exp):
|
||||
if datetime.now(timezone.utc) > datetime.fromtimestamp(exp):
|
||||
raise TokenExpiredException()
|
||||
|
||||
# Extract user data
|
||||
|
||||
Reference in New Issue
Block a user