mirror of https://github.com/jumpserver/jumpserver
fix: 修复用户登录失败未记录日志的问题
parent
d0bf815e9b
commit
ed408fb739
|
@ -39,7 +39,7 @@ class UserLoginLogViewSet(ListModelMixin, CommonGenericViewSet):
|
||||||
('datetime', ('date_from', 'date_to'))
|
('datetime', ('date_from', 'date_to'))
|
||||||
]
|
]
|
||||||
filterset_fields = ['username', 'ip', 'city', 'type', 'status', 'mfa']
|
filterset_fields = ['username', 'ip', 'city', 'type', 'status', 'mfa']
|
||||||
search_fields =['username', 'ip', 'city']
|
search_fields = ['username', 'ip', 'city']
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_org_members():
|
def get_org_members():
|
||||||
|
@ -48,9 +48,10 @@ class UserLoginLogViewSet(ListModelMixin, CommonGenericViewSet):
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
queryset = super().get_queryset()
|
queryset = super().get_queryset()
|
||||||
if not current_org.is_default():
|
if current_org.is_root():
|
||||||
users = self.get_org_members()
|
return queryset
|
||||||
queryset = queryset.filter(username__in=users)
|
users = self.get_org_members()
|
||||||
|
queryset = queryset.filter(username__in=users)
|
||||||
return queryset
|
return queryset
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -35,13 +35,14 @@ class UserLoginLogSerializer(serializers.ModelSerializer):
|
||||||
fields_mini = ['id']
|
fields_mini = ['id']
|
||||||
fields_small = fields_mini + [
|
fields_small = fields_mini + [
|
||||||
'username', 'type', 'type_display', 'ip', 'city', 'user_agent',
|
'username', 'type', 'type_display', 'ip', 'city', 'user_agent',
|
||||||
'mfa', 'mfa_display', 'reason', 'backend',
|
'mfa', 'mfa_display', 'reason', 'reason_display', 'backend',
|
||||||
'status', 'status_display',
|
'status', 'status_display',
|
||||||
'datetime',
|
'datetime',
|
||||||
]
|
]
|
||||||
fields = fields_small
|
fields = fields_small
|
||||||
extra_kwargs = {
|
extra_kwargs = {
|
||||||
"user_agent": {'label': _('User agent')}
|
"user_agent": {'label': _('User agent')},
|
||||||
|
"reason_display": {'label': _('Reason')}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -109,8 +109,7 @@ class UserLoginView(mixins.AuthMixin, FormView):
|
||||||
self.request.session.delete_test_cookie()
|
self.request.session.delete_test_cookie()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with transaction.atomic():
|
self.check_user_auth(decrypt_passwd=True)
|
||||||
self.check_user_auth(decrypt_passwd=True)
|
|
||||||
except errors.AuthFailedError as e:
|
except errors.AuthFailedError as e:
|
||||||
form.add_error(None, e.msg)
|
form.add_error(None, e.msg)
|
||||||
self.set_login_failed_mark()
|
self.set_login_failed_mark()
|
||||||
|
|
Loading…
Reference in New Issue