Some changes
This commit is contained in:
13
src/main.ts
13
src/main.ts
@@ -10,13 +10,14 @@ import ConfirmedForm from '@/components/ConfirmedForm.vue'
|
||||
import LoadingComponent from '@/components/LoadingComponent.vue'
|
||||
import axios from 'axios'
|
||||
import LoginModal from '@/components/LoginModal.vue'
|
||||
import { createPinia } from 'pinia'
|
||||
import { createPinia, storeToRefs } from 'pinia'
|
||||
import VueCookies from 'vue3-cookies'
|
||||
import { router } from '@/router/router'
|
||||
import { useSiteControlStore } from '@/stores/siteControl.store'
|
||||
import { useCategoriesStore } from '@/stores/categories.store'
|
||||
import { useOrdersStore } from '@/stores/orders.store'
|
||||
import { useContractorsStore } from '@/stores/contractors.store'
|
||||
import { useUserStore } from '@/stores/user.store'
|
||||
|
||||
const app = createApp(App);
|
||||
const pinia = createPinia();
|
||||
@@ -34,6 +35,16 @@ export const axiosInstance = axios.create({
|
||||
withCredentials: true
|
||||
});
|
||||
|
||||
axiosInstance.interceptors.response.use( (response) => {
|
||||
return response;
|
||||
}, (error) => {
|
||||
if (error.response.status == 401) {
|
||||
const userStore = useUserStore();
|
||||
storeToRefs(userStore).username.value = undefined;
|
||||
router.push('/login');
|
||||
}
|
||||
});
|
||||
|
||||
app.component('VueDatePicker', VueDatePicker);
|
||||
app.component('ConfirmationModal', ConfirmationModal);
|
||||
app.component('LoginModal', LoginModal);
|
||||
|
||||
Reference in New Issue
Block a user