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

1350
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -31,9 +31,9 @@
"postcss": "^8.4.27",
"tailwindcss": "^3.3.3",
"typescript": "^5.0.2",
"vite": "^5.2.11",
"vite": "^6.3.5",
"vite-plugin-runtime-env": "^0.1.1",
"vitest": "^1.6.0",
"vitest": "^3.1.3",
"vue-tsc": "^2.0.18"
}
}

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;