diff --git a/apps/audits/api.py b/apps/audits/api.py index 32cbdb3e0..2130c8333 100644 --- a/apps/audits/api.py +++ b/apps/audits/api.py @@ -39,7 +39,7 @@ class UserLoginLogViewSet(ListModelMixin, CommonGenericViewSet): ('datetime', ('date_from', 'date_to')) ] filterset_fields = ['username', 'ip', 'city', 'type', 'status', 'mfa'] - search_fields =['username', 'ip', 'city'] + search_fields = ['username', 'ip', 'city'] @staticmethod def get_org_members(): @@ -48,9 +48,10 @@ class UserLoginLogViewSet(ListModelMixin, CommonGenericViewSet): def get_queryset(self): queryset = super().get_queryset() - if not current_org.is_default(): - users = self.get_org_members() - queryset = queryset.filter(username__in=users) + if current_org.is_root(): + return queryset + users = self.get_org_members() + queryset = queryset.filter(username__in=users) return queryset diff --git a/apps/audits/serializers.py b/apps/audits/serializers.py index c83518285..32e8ad20d 100644 --- a/apps/audits/serializers.py +++ b/apps/audits/serializers.py @@ -35,13 +35,14 @@ class UserLoginLogSerializer(serializers.ModelSerializer): fields_mini = ['id'] fields_small = fields_mini + [ 'username', 'type', 'type_display', 'ip', 'city', 'user_agent', - 'mfa', 'mfa_display', 'reason', 'backend', + 'mfa', 'mfa_display', 'reason', 'reason_display', 'backend', 'status', 'status_display', 'datetime', ] fields = fields_small extra_kwargs = { - "user_agent": {'label': _('User agent')} + "user_agent": {'label': _('User agent')}, + "reason_display": {'label': _('Reason')} } diff --git a/apps/authentication/views/login.py b/apps/authentication/views/login.py index a33d8cee8..820edd950 100644 --- a/apps/authentication/views/login.py +++ b/apps/authentication/views/login.py @@ -109,8 +109,7 @@ class UserLoginView(mixins.AuthMixin, FormView): self.request.session.delete_test_cookie() try: - with transaction.atomic(): - self.check_user_auth(decrypt_passwd=True) + self.check_user_auth(decrypt_passwd=True) except errors.AuthFailedError as e: form.add_error(None, e.msg) self.set_login_failed_mark()