feat: handle unauthorized access by redirecting to login page in ChatPage

This commit is contained in:
Soulter
2025-06-10 21:21:38 +08:00
parent a34f439226
commit 417747d5d0
2 changed files with 4 additions and 0 deletions
+3
View File
@@ -697,6 +697,9 @@ export default {
}
}
}).catch(err => {
if (err.response.status === 401) {
this.$router.push('/auth/login?redirect=/chatbox');
}
console.error(err);
});
},
@@ -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;