From 417747d5d0bf7a126013f3e508a32ef21374a2fb Mon Sep 17 00:00:00 2001 From: Soulter <905617992@qq.com> Date: Tue, 10 Jun 2025 21:21:38 +0800 Subject: [PATCH] feat: handle unauthorized access by redirecting to login page in ChatPage --- dashboard/src/views/ChatPage.vue | 3 +++ dashboard/src/views/authentication/authForms/AuthLogin.vue | 1 + 2 files changed, 4 insertions(+) diff --git a/dashboard/src/views/ChatPage.vue b/dashboard/src/views/ChatPage.vue index aeefb9530..3a7966c0c 100644 --- a/dashboard/src/views/ChatPage.vue +++ b/dashboard/src/views/ChatPage.vue @@ -697,6 +697,9 @@ export default { } } }).catch(err => { + if (err.response.status === 401) { + this.$router.push('/auth/login?redirect=/chatbox'); + } console.error(err); }); }, diff --git a/dashboard/src/views/authentication/authForms/AuthLogin.vue b/dashboard/src/views/authentication/authForms/AuthLogin.vue index 1273be947..d97ade8f4 100644 --- a/dashboard/src/views/authentication/authForms/AuthLogin.vue +++ b/dashboard/src/views/authentication/authForms/AuthLogin.vue @@ -23,6 +23,7 @@ async function validate(values: any, { setErrors }: any) { } const authStore = useAuthStore(); + authStore.returnUrl = new URLSearchParams(window.location.search).get('redirect') || null; return authStore.login(username.value, password_).then((res) => { console.log(res); loading.value = false;