[Bugfix] user login ip

This commit is contained in:
ibuler
2018-01-16 09:58:33 +08:00
parent dad21cadb3
commit 29061aa088
4 changed files with 16 additions and 6 deletions

View File

@@ -180,8 +180,9 @@ def validate_ip(ip):
def write_login_log(username, type='', ip='', user_agent=''):
if not (ip and validate_ip(ip)):
ip = '0.0.0.0'
city = get_ip_city(ip)
city = "Unknown"
else:
city = get_ip_city(ip)
LoginLog.objects.create(
username=username, type=type,
ip=ip, city=city, user_agent=user_agent