From f4c835d47a0ef062e34bf92355d451678fba6e8d Mon Sep 17 00:00:00 2001 From: BaiJiangJie Date: Wed, 24 Jul 2019 15:49:37 +0800 Subject: [PATCH] =?UTF-8?q?[Bugfix]=20=E8=A7=A3=E5=86=B3=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E7=99=BB=E5=BD=95=E6=97=A5=E5=BF=97=E8=AE=B0=E5=BD=95=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E7=9A=84=E9=97=AE=E9=A2=98=EF=BC=88coco=E7=AB=AF?= =?UTF-8?q?=E7=99=BB=E5=BD=95=E8=AE=B0=E5=BD=95=E7=B1=BB=E5=9E=8B=E4=B8=BA?= =?UTF-8?q?Web=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/authentication/signals_handlers.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/apps/authentication/signals_handlers.py b/apps/authentication/signals_handlers.py index e401b7dc1..7033cf777 100644 --- a/apps/authentication/signals_handlers.py +++ b/apps/authentication/signals_handlers.py @@ -1,3 +1,4 @@ +from rest_framework.request import Request from django.http.request import QueryDict from django.conf import settings from django.dispatch import receiver @@ -52,14 +53,15 @@ def on_ldap_create_user(sender, user, ldap_user, **kwargs): def generate_data(username, request): - if not request.user.is_anonymous and request.user.is_app: + user_agent = request.META.get('HTTP_USER_AGENT', '') + + if isinstance(request, Request): login_ip = request.data.get('remote_addr', None) login_type = request.data.get('login_type', '') - user_agent = request.data.get('HTTP_USER_AGENT', '') else: login_ip = get_request_ip(request) - user_agent = request.META.get('HTTP_USER_AGENT', '') login_type = 'W' + data = { 'username': username, 'ip': login_ip,