feat(停用账号): 停用/删除即强制下线并点名成因——写入口、X-Auth-Reason 头、三面接线

- Java:AdminUserUpdateRequest 加 disabled 开关(不能停自己、归属门沿用既有闸),
  AccountExpiryService/AdminAuthSupport 抛停用/删除子类型,GlobalExceptionHandler 打
  X-Auth-Reason: disabled|deleted 响应头;业务码保持 401 不变,不惊动三个既有消费者
- 后台管理:用户页停用/解除停用按钮 + 已停用徽章;拦截器把成因随 &auth= 带给登录页,
  登录页分停用/删除两种文案;源码钉子棘轮基线按正路重生成
- 用户端:kick-handler 按 X-Auth-Reason 分支亮停用/删除标记(互斥清理),
  登录页两段专属文案且各自关自动登录;跳转目标仍是 /login?expired=1
- 反假绿:摘掉成因头注入实测 2/4 红(变异自证),还原等值后复跑回绿
This commit is contained in:
2026-10-09 16:35:35 +08:00
parent 3c2fd54e3e
commit 24a94428e8
25 changed files with 704 additions and 31 deletions
@@ -1,5 +1,6 @@
package com.nanri.aiimage.common.security;
import com.nanri.aiimage.common.exception.AccountDisabledException;
import com.nanri.aiimage.common.exception.BusinessException;
import com.nanri.aiimage.common.mapper.AdminUserMapper;
import com.nanri.aiimage.common.mapper.ShopManageGroupMapper;
@@ -87,7 +88,8 @@ public class AccountExpiryService {
*/
private static void assertNotDisabled(java.time.LocalDateTime disabledAt, int code) {
if (disabledAt != null) {
throw new BusinessException(code, "账号已停用,请联系管理员");
// 子类型只为了让 GlobalExceptionHandler 打 X-Auth-Reason: disabled;码与文案不变
throw new AccountDisabledException(code, "账号已停用,请联系管理员");
}
}
@@ -2,6 +2,7 @@ package com.nanri.aiimage.common.security;
import java.util.List;
import java.util.ArrayList;
import com.nanri.aiimage.common.exception.AccountDeletedException;
import com.nanri.aiimage.common.exception.BusinessException;
import com.nanri.aiimage.common.security.JwtService;
import com.nanri.aiimage.common.security.DeviceSessionPolicy;
@@ -66,7 +67,7 @@ public class AdminAuthSupport {
AdminUserEntity user = adminUserMapper.selectById(userId);
if (user == null) {
// 硬删账号会留下孤儿在跑行:认人必须排在容忍之前,否则已删账号被自己的孤儿行继续供着
throw new BusinessException(401, "用户不存在");
throw new AccountDeletedException(401, "用户不存在");
}
// 吊销先于单设备比对:那条路径第一行就是 if (exempt) return;(超管豁免),
// 把吊销挂在它下面等于超管永不见吊销