From 35ca6377fe387a376330cc64f4eb5e64d63d2b49 Mon Sep 17 00:00:00 2001 From: Luca Date: Tue, 24 Sep 2024 14:59:40 +0200 Subject: [PATCH] Attempt fix redirect --- src/main.js | 6 +++++- src/store/index.js | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main.js b/src/main.js index a2a5fe9..8da55b7 100644 --- a/src/main.js +++ b/src/main.js @@ -31,10 +31,10 @@ import "./Slider.scss"; import "./App.scss"; import 'sweetalert2/dist/sweetalert2.min.css'; import App from '@/App'; +import mitt from 'mitt'; import Footer from '@/Footer'; import router from '@/router'; import storeA from '@/store'; -import mitt from 'mitt'; import BootstrapVueNext from 'bootstrap-vue-next' import VueSweetalert2 from 'vue-sweetalert2'; @@ -82,6 +82,10 @@ Sentry.init({ }); } +emitter.on('logout', () => { + router.push('/account/login'); + utils.setLogin(""); +}); app.mount('#app'); diff --git a/src/store/index.js b/src/store/index.js index 577f33b..7d9b48c 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -1,6 +1,5 @@ import { createStore } from 'vuex'; import axios from "axios"; -import router from '@/router'; const store = createStore({ state() { @@ -95,7 +94,8 @@ const store = createStore({ console.log("Successfully fetched self"); return; } else if(res.status === 401) { - router.push('/account/login'); + emitter.emit('logout'); + return; } else console.log("Self status code is " + res.status + " with message " + res.data); } catch (e) { console.log(e);