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:
@@ -5,7 +5,7 @@ import axios, {
|
||||
type AxiosResponse,
|
||||
type InternalAxiosRequestConfig,
|
||||
} from 'axios'
|
||||
import { handleKicked, handleSessionExpired, isKickedPayload, isUnauthorizedPayload } from '../auth/kick-handler.ts'
|
||||
import { authReasonOf, handleKicked, handleSessionExpired, isKickedPayload, isUnauthorizedPayload } from '../auth/kick-handler.ts'
|
||||
|
||||
export interface LegacyApiSuccess<T> {
|
||||
success: true
|
||||
@@ -61,12 +61,17 @@ function responseStatusOf(error: unknown): unknown {
|
||||
return (error as { response?: { status?: unknown } } | null | undefined)?.response?.status
|
||||
}
|
||||
|
||||
/** 从 axios 错误对象里取响应头(兼容真实 AxiosError 与测试桩)。 */
|
||||
function responseHeadersOf(error: unknown): unknown {
|
||||
return (error as { response?: { headers?: unknown } } | null | undefined)?.response?.headers
|
||||
}
|
||||
|
||||
/** 响应成功分支:Java 业务错误是 HTTP 200 + body.code,下线收口必须在这里也判。 */
|
||||
export function onResponseFulfilled(response: AxiosResponse): AxiosResponse {
|
||||
if (isKickedPayload(response.data)) {
|
||||
handleKicked()
|
||||
} else if (isUnauthorizedPayload(response.data)) {
|
||||
handleSessionExpired()
|
||||
handleSessionExpired(authReasonOf(response.headers))
|
||||
}
|
||||
return response
|
||||
}
|
||||
@@ -77,7 +82,7 @@ export function onResponseRejected(error: unknown): Promise<never> {
|
||||
if (isKickedPayload(payload)) {
|
||||
handleKicked()
|
||||
} else if (isUnauthorizedPayload(payload) || responseStatusOf(error) === 401) {
|
||||
handleSessionExpired()
|
||||
handleSessionExpired(authReasonOf(responseHeadersOf(error)))
|
||||
}
|
||||
return Promise.reject(new Error(extractErrorMessage(error)))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user