feat: 异地登录提醒可配置是否启用

This commit is contained in:
xinwen
2021-11-08 15:12:12 +08:00
committed by 老广
parent f9e970f4ed
commit bac974b4f2
6 changed files with 26 additions and 4 deletions

View File

@@ -5,6 +5,7 @@ from Cryptodome.PublicKey import RSA
from Cryptodome.Cipher import PKCS1_v1_5
from Cryptodome import Random
from django.conf import settings
from .notifications import DifferentCityLoginMessage
from audits.models import UserLoginLog
from audits.const import DEFAULT_CITY
@@ -51,7 +52,10 @@ def rsa_decrypt(cipher_text, rsa_private_key=None):
return message
def check_different_city_login(user, request):
def check_different_city_login_if_need(user, request):
if not settings.SECURITY_CHECK_DIFFERENT_CITY_LOGIN:
return
ip = get_request_ip(request) or '0.0.0.0'
if not (ip and validate_ip(ip)):