hotfixy routingów

This commit is contained in:
2023-09-16 18:59:37 +02:00
parent 48efd21178
commit 7c0accbbce
4 changed files with 11 additions and 41 deletions
+7 -9
View File
@@ -1,7 +1,7 @@
<template>
<PopUpCard v-if="store.alertMessage || store.confirmMessage" />
<router-view></router-view>
<router-view v-if="!tokenLoading"></router-view>
</template>
<script lang="ts">
@@ -9,7 +9,6 @@ import { defineComponent } from 'vue';
import PopUpCard from './components/PopUpCard.vue';
import { RouterView } from 'vue-router';
import { AuthState } from './types/types';
import useRouteGuard from './mixins/useRouteGuard';
import { baseURL, useStore } from './store';
import useLocalStorage from './mixins/useLocalStorage';
import axios from 'axios';
@@ -18,21 +17,20 @@ export default defineComponent({
components: { PopUpCard },
setup() {
const { routeAuthGuard } = useRouteGuard();
const { setupStorage } = useLocalStorage();
// routeAuthGuard();
setupStorage();
return {
store: useStore(),
tokenLoading: false,
};
},
methods: {
async autoLogin() {
try {
this.store.authState = AuthState.LOADING;
this.tokenLoading = true;
const response = await axios.post(
'/auth/token',
@@ -43,14 +41,14 @@ export default defineComponent({
}
);
this.store.user = response.data;
this.store.authState = AuthState.AUTHORIZED;
this.$router.push('/');
this.store.user = response.data;
} catch (error) {
this.$router.push('/login');
this.store.authState = AuthState.UNAUTHORIZED;
this.store.user = null;
}
this.tokenLoading = false;
},
},