Repository: TencentBlueKing/bk-user

Issue:
【BUG】异常状态用户登录，登录审计记录该用户已被删除
**用文字描述你遇到的问题**

异常状态用户登录，登录审计记录该用户已被删除

**重现方法**

![image](https://github.com/TencentBlueKing/bk-user/assets/49228807/1c1ebdb5-8656-4fb1-9a90-12986b151745)

![image](https://github.com/TencentBlueKing/bk-user/assets/49228807/c52e8211-79af-4b1e-a5a0-255372d9e0c1)

**预期行为**

显示正常的失败原因

**版本**
2.5.2
- 是否是企业版问题？

**如果是 SaaS 页面问题，请提供使用的操作系统和浏览器信息**
 - OS: [e.g. iOS]
 - Browser [e.g. chrome, safari]
 - Version [e.g. 22]

**额外信息**

任何你觉得有助于问题解决的内容



Discussion:

Resolving patch:
diff --git a/src/api/bkuser_core/api/login/views.py b/src/api/bkuser_core/api/login/views.py
--- a/src/api/bkuser_core/api/login/views.py
+++ b/src/api/bkuser_core/api/login/views.py
@@ -110,13 +110,17 @@ def login(self, request):
                 ProfileStatus.DISABLED.value,
                 ProfileStatus.DELETED.value,
             ]:
+                if profile.status == ProfileStatus.DISABLED.value:
+                    failed_reason = LogInFailReason.DISABLED_USER.value
+                else:
+                    failed_reason = LogInFailReason.DELETED_USER.value
                 create_profile_log(
                     profile=profile,
                     operation="LogIn",
                     request=request,
-                    params={"is_success": False, "reason": LogInFailReason.DISABLED_USER.value},
+                    params={"is_success": False, "reason": failed_reason},
                 )
-                logger.info("login check, profile<%s> of %s is disabled or deleted", profile.username, message_detail)
+                logger.info("login check, profile<%s> of %s is %s", profile.username, message_detail, profile.status)
                 raise error_codes.PASSWORD_ERROR
                 # NOTE: 安全原因, 不能返回账户状态
                 # if profile.status == ProfileStatus.DISABLED.value:
diff --git a/src/api/bkuser_core/api/web/audit/constants.py b/src/api/bkuser_core/api/web/audit/constants.py
--- a/src/api/bkuser_core/api/web/audit/constants.py
+++ b/src/api/bkuser_core/api/web/audit/constants.py
@@ -36,8 +36,8 @@
     ("forget_password", _("用户通过token重置密码")),
     ("admin_reset_password", _("管理员重置密码")),
     ("modify_password", _("用户通过旧密码修改")),
-    ("set_field_visible", "设置字段展示"),
-    ("set_field_invisible", "设置字段隐藏"),
+    ("set_field_visible", _("设置字段展示")),
+    ("set_field_invisible", _("设置字段隐藏")),
 )
 
 OPERATION_VALUE_MAP = {x[1]: x[0] for x in OPERATION_NAME_TUPLE}
@@ -56,7 +56,8 @@
     ("expired_password", _("密码过期")),
     ("too_many_failure", _("密码错误次数过多")),
     ("locked_user", _("用户已锁定")),
-    ("disabled_user", _("用户已删除")),
+    ("disabled_user", _("用户已禁用")),
+    ("deleted_user", _("用户已删除")),
     ("should_change_initial_password", _("需要修改初始密码")),
     ("expired_user", _("用户账号已过期")),
 )
diff --git a/src/api/bkuser_core/audit/constants.py b/src/api/bkuser_core/audit/constants.py
--- a/src/api/bkuser_core/audit/constants.py
+++ b/src/api/bkuser_core/audit/constants.py
@@ -21,6 +21,7 @@ class LogInFailReason(AutoLowerEnum):
     TOO_MANY_FAILURE = auto()
     LOCKED_USER = auto()
     DISABLED_USER = auto()
+    DELETED_USER = auto()
     EXPIRED_USER = auto()
     RESIGNED_USER = auto()
     SHOULD_CHANGE_INITIAL_PASSWORD = auto()
@@ -30,7 +31,8 @@ class LogInFailReason(AutoLowerEnum):
         (EXPIRED_PASSWORD, "密码过期"),
         (TOO_MANY_FAILURE, "密码错误次数过多"),
         (LOCKED_USER, "用户已锁定"),
-        (DISABLED_USER, "用户已删除"),
+        (DISABLED_USER, "用户已禁用"),
+        (DELETED_USER, "用户已删除"),
         (EXPIRED_USER, "用户账号已过期"),
         (RESIGNED_USER, "用户已离职"),
         (SHOULD_CHANGE_INITIAL_PASSWORD, "需要修改初始密码"),


Test patch: