diff --git a/apps/audits/signals_handler.py b/apps/audits/signals_handler.py index d2a728f95..393f51a37 100644 --- a/apps/audits/signals_handler.py +++ b/apps/audits/signals_handler.py @@ -108,10 +108,10 @@ def generate_data(username, request): user_agent = request.META.get('HTTP_USER_AGENT', '') if isinstance(request, Request): - login_ip = request.data.get('remote_addr', None) + login_ip = request.data.get('remote_addr', '0.0.0.0') login_type = request.data.get('login_type', '') else: - login_ip = get_request_ip(request) + login_ip = get_request_ip(request) or '0.0.0.0' login_type = 'W' data = { diff --git a/apps/authentication/api/login_confirm.py b/apps/authentication/api/login_confirm.py index 45faddac6..d2555eae4 100644 --- a/apps/authentication/api/login_confirm.py +++ b/apps/authentication/api/login_confirm.py @@ -50,7 +50,7 @@ class UserOrderAcceptAuthApi(APIView): elif order.status == order.STATUS_REJECTED: raise errors.LoginConfirmRejectedError(order_id) else: - return errors.LoginConfirmWaitError(order_id) + raise errors.LoginConfirmWaitError(order_id) except errors.AuthFailedError as e: data = e.as_data() return Response(data, status=400) diff --git a/apps/authentication/api/token.py b/apps/authentication/api/token.py index e0db1bcc3..7242cf9b5 100644 --- a/apps/authentication/api/token.py +++ b/apps/authentication/api/token.py @@ -36,4 +36,4 @@ class TokenCreateApi(AuthMixin, CreateAPIView): resp = super().create(request, *args, **kwargs) return resp except errors.AuthFailedError as e: - return Response(e.as_data(), status=401) + return Response(e.as_data(), status=400) diff --git a/apps/authentication/errors.py b/apps/authentication/errors.py index 0a5d42e77..9a5957135 100644 --- a/apps/authentication/errors.py +++ b/apps/authentication/errors.py @@ -139,8 +139,10 @@ class MFARequiredError(AuthFailedError): return { 'error': self.error, 'msg': self.msg, - 'choices': ['otp'], - 'url': reverse('api-auth:mfa-challenge') + 'data': { + 'choices': ['otp'], + 'url': reverse('api-auth:mfa-challenge') + } } @@ -161,7 +163,9 @@ class LoginConfirmError(AuthFailedError): return { "error": self.error, "msg": self.msg, - "order_id": self.order_id + "data": { + "order_id": self.order_id + } } diff --git a/apps/authentication/mixins.py b/apps/authentication/mixins.py index 02d728b2d..ec8965369 100644 --- a/apps/authentication/mixins.py +++ b/apps/authentication/mixins.py @@ -114,6 +114,7 @@ class AuthMixin: self.request.session['auth_password'] = '' self.request.session['auth_mfa'] = '' self.request.session['auth_confirm'] = '' + self.request.session['auth_order_id'] = '' def send_auth_signal(self, success=True, user=None, username='', reason=''): if success: diff --git a/apps/orders/signals_handler.py b/apps/orders/signals_handler.py index 60db0c5e5..9c25907f7 100644 --- a/apps/orders/signals_handler.py +++ b/apps/orders/signals_handler.py @@ -20,7 +20,6 @@ def on_login_confirm_order_assignees_set(sender, instance=None, action=None, if action == 'post_add': logger.debug('New order create, send mail: {}'.format(instance.id)) assignees = model.objects.filter(pk__in=pk_set) - print(assignees) send_login_confirm_order_mail_to_assignees(instance, assignees)