From 6a518b55253c2e79634d64d1a49e0af73987ba49 Mon Sep 17 00:00:00 2001 From: Om Date: Wed, 2 Sep 2026 16:19:01 +0530 Subject: [PATCH] fix(backend): use timezone.now() for licensing and analytics timestamps issued_at was written to a DateTimeField as a naive server-local datetime under USE_TZ, the license expiry check compared a server-local date against the license date, and the decrypt-count chart window started from a naive now(). Matches the timezone.now() used in the other 143 call sites. --- backend/backend/schema.py | 2 +- backend/ee/licensing/utils.py | 4 ++-- backend/ee/licensing/verifier.py | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/backend/backend/schema.py b/backend/backend/schema.py index 59c70c12b..c44aa6538 100644 --- a/backend/backend/schema.py +++ b/backend/backend/schema.py @@ -1405,7 +1405,7 @@ def resolve_app_activity_chart(root, info, app_id, period=TimeRange.DAY): if not user_can_access_app(info.context.user.userId, app_id): raise GraphQLError("You don't have access to this app") - end_date = datetime.now() # current time + end_date = timezone.now() # current time # default values for period='day' # 24 hours before current time diff --git a/backend/ee/licensing/utils.py b/backend/ee/licensing/utils.py index ab9de004f..23b7d9c9c 100644 --- a/backend/ee/licensing/utils.py +++ b/backend/ee/licensing/utils.py @@ -141,9 +141,9 @@ def activate_license(phase_license): phase_license.signature_date, "%Y-%m-%d" ), "issuing_authority": phase_license.issuing_authority, - "issued_at": datetime.now(), + "issued_at": timezone.now(), "expires_at": phase_license.expires_at, - "activated_at": datetime.now(), + "activated_at": timezone.now(), } if phase_license.plan == PlanTier.PRO_PLAN.value: diff --git a/backend/ee/licensing/verifier.py b/backend/ee/licensing/verifier.py index a228e9e83..c94433388 100644 --- a/backend/ee/licensing/verifier.py +++ b/backend/ee/licensing/verifier.py @@ -2,6 +2,7 @@ from nacl import encoding, signing, exceptions from .utils import PhaseLicense, parse_license_format from datetime import datetime +from django.utils import timezone import json VERIFIER_KEYS = [ @@ -30,7 +31,7 @@ def verify_signature(public_key_hex, license_str): data["issued_at"] = datetime.strptime(data["issued_at"], "%Y-%m-%d").date() data["expires_at"] = datetime.strptime(data["expires_at"], "%Y-%m-%d").date() - if datetime.now().date() > data["expires_at"]: + if timezone.now().date() > data["expires_at"]: print("License is expired.") valid = False else: