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()