mirror of
https://github.com/Spythere/station-manager-2.0.git
synced 2026-05-03 05:28:13 +00:00
hotfixy routingów
This commit is contained in:
+7
-9
@@ -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;
|
||||
},
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user