update an fix login

This commit is contained in:
2025-05-10 09:30:16 +02:00
parent 00c37c0a37
commit 778de8ca14
3 changed files with 618 additions and 750 deletions
+10 -4
View File
@@ -10,13 +10,13 @@ export const marbasAxiosInstance = axios.create({
},
})
marbasAxiosInstance.interceptors.request.use(r => {
const authStore = useAuthStore();
const authStore = useAuthStore();
marbasAxiosInstance.interceptors.request.use(async r => {
if (!authStore.isLoggedIn) {
throw new Error("Not logged in");
await authStore.redirect();
}
const accessToken = authStore.accessToken;
if (accessToken) {
@@ -29,6 +29,12 @@ marbasAxiosInstance.interceptors.request.use(r => {
})
logResource(marbasAxiosInstance)
marbasAxiosInstance.interceptors.response.use(async r => {
if (r.status === 401) {
await authStore.redirect();
return marbasAxiosInstance.request(r.config);
}
let next: string = r.data?.next;
let results = r.data?.results;