update an fix login
This commit is contained in:
1350
package-lock.json
generated
1350
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -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"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user