feat: Standardize audit log timestamps to UTC in the backend and display local time in the frontend.
This commit is contained in:
@@ -40,9 +40,9 @@ class AuditService:
|
||||
"""
|
||||
Low-level creation of an Audit Log entry
|
||||
"""
|
||||
# Timezone handling set to Hermosillo (Sonora) to match user preference (-1h vs CDMX)
|
||||
tz = pytz.timezone('America/Hermosillo')
|
||||
now = datetime.now(tz)
|
||||
# Timezone handling: Use UTC for consistency across regions.
|
||||
# Frontend will convert to user's local time.
|
||||
now = datetime.now(pytz.UTC)
|
||||
|
||||
log = AuditLog(
|
||||
reference=reference,
|
||||
@@ -157,9 +157,8 @@ class AuditService:
|
||||
# Prevent duplicate login logs (debounce 5 seconds)
|
||||
# This handles cases where frontend might submit twice or redirects trigger re-auth
|
||||
try:
|
||||
# Timezone handling set to Hermosillo (Sonora) to match user preference (-1h vs CDMX)
|
||||
tz = pytz.timezone('America/Hermosillo')
|
||||
now = datetime.now(tz)
|
||||
# Timezone handling: Use UTC for consistency
|
||||
now = datetime.now(pytz.UTC)
|
||||
five_seconds_ago = now - datetime.timedelta(seconds=5)
|
||||
|
||||
# Check for recent login from same user
|
||||
|
||||
Reference in New Issue
Block a user