feat: handle unauthorized access by redirecting to login page in ChatPage
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user