From 55775f0deb5e22808ed94acf76436d43a2c99d55 Mon Sep 17 00:00:00 2001 From: feng626 <1304903146@qq.com> Date: Tue, 2 Nov 2021 15:41:25 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E5=BC=82=E5=9C=B0=E7=99=BB=E9=99=86?= =?UTF-8?q?=E5=8E=BB=E6=8E=89=E6=9C=AC=E5=9C=B0=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/authentication/utils.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/apps/authentication/utils.py b/apps/authentication/utils.py index 6e8e45570..0e1dd5e9c 100644 --- a/apps/authentication/utils.py +++ b/apps/authentication/utils.py @@ -59,6 +59,10 @@ def check_different_city_login(user, request): else: city = get_ip_city(ip) or DEFAULT_CITY - last_user_login = UserLoginLog.objects.filter(username=user.username, status=True).first() - if last_user_login and last_user_login.city != city: - DifferentCityLoginMessage(user, ip, city).publish_async() + city_white = ['LAN', ] + if city not in city_white: + last_user_login = UserLoginLog.objects.exclude(city__in=city_white) \ + .filter(username=user.username, status=True).first() + + if last_user_login and last_user_login.city != city: + DifferentCityLoginMessage(user, ip, city).publish_async()