From 55b6887c5e1c17e0af2bc70837f3755eccf55f91 Mon Sep 17 00:00:00 2001 From: pajowu Date: Tue, 28 Jul 2026 09:08:00 +0200 Subject: [PATCH] Show new login time in users timezone (Z#23241469) (#6420) --- src/pretix/helpers/security.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pretix/helpers/security.py b/src/pretix/helpers/security.py index 847aed36d6..37d100d28b 100644 --- a/src/pretix/helpers/security.py +++ b/src/pretix/helpers/security.py @@ -28,7 +28,7 @@ from django.contrib.auth import login as auth_login from django.contrib.gis import geoip2 from django.core.cache import cache from django.utils.formats import date_format -from django.utils.timezone import now +from django.utils.timezone import localtime, now, override from django.utils.translation import gettext_lazy as _ from django_countries.fields import Country from geoip2.errors import AddressNotFoundError @@ -167,13 +167,13 @@ def handle_login_source(user, request): }) if user.known_login_sources.count() > 1: # Do not send on first login or first login after introduction of this feature: - with language(user.locale): + with language(user.locale), override(user.timezone): mail( user.email, _('New sign-in to your account'), 'pretixcontrol/email/login_notice.txt', { - 'when': date_format(src.last_seen, 'DATETIME_FORMAT'), + 'when': date_format(localtime(src.last_seen), 'DATETIME_FORMAT'), 'agent': src.agent_type, 'os': src.os_type, # ua-parser returns "Other" for unidentified desktop devices.