From 5fc327a14d73c5e4984c72720d9e408e73f3dad0 Mon Sep 17 00:00:00 2001 From: ouyangxq <775153912@qq.com> Date: Thu, 13 Aug 2026 12:22:39 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/http.ts | 2 +- src/modules/auth/views/AuthViews.test.mjs | 7 +++++++ src/modules/auth/views/LoginView.vue | 8 ++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/api/http.ts b/src/api/http.ts index 977ead7..914acfb 100644 --- a/src/api/http.ts +++ b/src/api/http.ts @@ -95,7 +95,7 @@ transport.interceptors.response.use( (response) => response, async (error: AxiosError) => { const request = error.config as RetryableRequest | undefined - const publicAuthPaths = ['/auth/login', '/auth/register', '/auth/refresh'] + const publicAuthPaths = ['/auth/login', '/auth/register', '/auth/refresh', '/auth/impersonations/exchange'] const isPublicAuthRequest = publicAuthPaths.some((path) => request?.url?.endsWith(path)) if (error.response?.status !== 401 || !request || request._retriedAfterRefresh || isPublicAuthRequest) { throw mapError(error) diff --git a/src/modules/auth/views/AuthViews.test.mjs b/src/modules/auth/views/AuthViews.test.mjs index a7d762e..31f9a98 100644 --- a/src/modules/auth/views/AuthViews.test.mjs +++ b/src/modules/auth/views/AuthViews.test.mjs @@ -92,6 +92,13 @@ test('uses real auth endpoints and single-flight refresh handling', () => { assert.doesNotMatch(authStoreSource, /mock-client:/) }) +test('handles impersonation exchange as public authentication and exposes failures', () => { + assert.match(httpSource, /publicAuthPaths = \[[^\]]*'\/auth\/impersonations\/exchange'/) + assert.match(authStoreSource, /\/login\?impersonation=failed/) + assert.match(loginSource, /route\.query\.impersonation === 'failed'/) + assert.match(loginSource, /代登录失败或授权已失效,请返回管理后台重新发起/) +}) + test('treats only body code 200 as success', () => { assert.match(httpSource, /if \(envelope\.code !== '200'\)/) assert.doesNotMatch(httpSource, /if \(envelope\.code !== '0'\)/) diff --git a/src/modules/auth/views/LoginView.vue b/src/modules/auth/views/LoginView.vue index 6d25987..ba3cda6 100644 --- a/src/modules/auth/views/LoginView.vue +++ b/src/modules/auth/views/LoginView.vue @@ -17,6 +17,7 @@ const router = useRouter() const auth = useAuthStore() const formRef = ref() const loading = ref(false) +const impersonationFailed = route.query.impersonation === 'failed' const form = reactive({ account: typeof route.query.account === 'string' ? route.query.account @@ -77,6 +78,13 @@ function showResetHint() {

登录客户工作台

使用企业账号登录,继续管理您的跨境物流业务。

+