Skip to content

Commit

Permalink
fix: 审计支持失败记录 #71
Browse files Browse the repository at this point in the history
  • Loading branch information
Canway-shiisa committed Oct 21, 2021
1 parent 31607b4 commit 2efab88
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 5 deletions.
18 changes: 18 additions & 0 deletions src/api/bkuser_core/audit/migrations/0004_auto_20211021_1852.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.2.5 on 2021-10-21 10:52

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('audit', '0003_auto_20210516_1652'),
]

operations = [
migrations.AddField(
model_name='generallog',
name='status',
field=models.CharField(choices=[('succeed', '成功'), ('failed', '失败')], default='successed', max_length=16, verbose_name='状态'),
),
]
6 changes: 3 additions & 3 deletions src/api/bkuser_core/categories/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
from django.utils.decorators import method_decorator
from django.utils.module_loading import import_string
from drf_yasg.utils import swagger_auto_schema
from rest_framework import filters
from rest_framework import filters, status
from rest_framework.decorators import action
from rest_framework.parsers import FormParser, MultiPartParser
from rest_framework.response import Response
Expand Down Expand Up @@ -112,7 +112,7 @@ def create(self, request, *args, **kwargs):
serializer = self.get_serializer(data=request.data)
serializer.is_valid(raise_exception=True)
instance = serializer.save()
# headers = self.get_success_headers(serializer.data)
headers = self.get_success_headers(serializer.data)

# 默认添加到最后 TODO: 需要一个更优雅的实现
max_order = ProfileCategory.objects.get_max_order()
Expand All @@ -125,14 +125,14 @@ def create(self, request, *args, **kwargs):
operator_obj=instance,
request=request,
)
return Response(serializer.data, status=status.HTTP_201_CREATED, headers=headers)

def get_serializer(self, *args, **kwargs):
if self.action in ["create"]:
return CreateCategorySerializer(*args, **kwargs)
else:
return self.serializer_class(*args, **kwargs)

# @method_decorator(audit_error_general_log)
@audit_error_general_log(operate_type=OperationEnum.UPDATE.value)
@method_decorator(clear_cache_if_succeed)
def update(self, request, *args, **kwargs):
Expand Down
3 changes: 1 addition & 2 deletions src/api/bkuser_core/profiles/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from collections import defaultdict
from operator import or_

from bkuser_core.audit.constants import LogInFailReasonEnum, OperationEnum, OperationStatusEnum
from bkuser_core.audit.constants import LogInFailReasonEnum, OperationEnum
from bkuser_core.audit.utils import create_general_log, create_profile_log
from bkuser_core.categories.constants import CategoryType
from bkuser_core.categories.loader import get_plugin_by_category
Expand Down Expand Up @@ -427,7 +427,6 @@ def modify_password(self, request, *args, **kwargs):
operator=request.operator,
extra_values=modify_summary,
operation_type=OperationEnum.UPDATE.value,
status=OperationStatusEnum.SUCCEED.value,
)
return Response(data=local_serializers.ProfileMinimalSerializer(instance).data)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.2.5 on 2021-09-26 11:08

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('user_settings', '0008_auto_20210706_1702'),
]

operations = [
migrations.AlterField(
model_name='settingmeta',
name='category_type',
field=models.CharField(choices=[('local', '本地目录'), ('mad', 'Microsoft Active Directory'), ('ldap', 'OpenLDAP'), ('tof', 'TOF'), ('custom', '自定义目录'), ('pluggable', '可插拔目录')], max_length=32, verbose_name='类型'),
),
]

0 comments on commit 2efab88

Please sign in to comment.