Fix datetime

This commit is contained in:
Urtzi Alfaro
2025-07-17 15:02:25 +02:00
parent cb80a93c4b
commit a9e6cdae09
19 changed files with 54 additions and 54 deletions

View File

@@ -61,7 +61,7 @@ class AuthService:
UserRegisteredEvent(
event_id="",
service_name="auth-service",
timestamp=datetime.utcnow(),
timestamp= datetime.now(datetime.timezone.utc),
data={
"user_id": str(user.id),
"email": user.email,
@@ -111,7 +111,7 @@ class AuthService:
await db.execute(
update(User)
.where(User.id == user.id)
.values(last_login=datetime.utcnow())
.values(last_login= datetime.now(datetime.timezone.utc))
)
await db.commit()
@@ -133,7 +133,7 @@ class AuthService:
session = UserSession(
user_id=user.id,
refresh_token_hash=security_manager.hash_password(refresh_token),
expires_at=datetime.utcnow() + timedelta(days=7),
expires_at= datetime.now(datetime.timezone.utc) + timedelta(days=7),
ip_address=ip_address,
user_agent=user_agent
)
@@ -148,7 +148,7 @@ class AuthService:
UserLoginEvent(
event_id="",
service_name="auth-service",
timestamp=datetime.utcnow(),
timestamp= datetime.now(datetime.timezone.utc),
data={
"user_id": str(user.id),
"email": user.email,

View File

@@ -22,9 +22,9 @@ class JWTHandler:
to_encode = data.copy()
if expires_delta:
expire = datetime.utcnow() + expires_delta
expire = datetime.now(datetime.timezone.utc) + expires_delta
else:
expire = datetime.utcnow() + timedelta(minutes=30)
expire = datetime.now(datetime.timezone.utc) + timedelta(minutes=30)
to_encode.update({"exp": expire, "type": "access"})
@@ -36,9 +36,9 @@ class JWTHandler:
to_encode = data.copy()
if expires_delta:
expire = datetime.utcnow() + expires_delta
expire = datetime.now(datetime.timezone.utc) + expires_delta
else:
expire = datetime.utcnow() + timedelta(days=7)
expire = datetime.now(datetime.timezone.utc) + timedelta(days=7)
to_encode.update({"exp": expire, "type": "refresh"})

View File

@@ -21,7 +21,7 @@ class BaseEvent:
if not self.event_id:
self.event_id = str(uuid.uuid4())
if not self.timestamp:
self.timestamp = datetime.utcnow()
self.timestamp = datetime.now(datetime.timezone.utc)
# Training Events
@dataclass