diff --git a/src/Services/http.js b/src/Services/http.js index 99c6a38..b14f50b 100644 --- a/src/Services/http.js +++ b/src/Services/http.js @@ -32,6 +32,7 @@ export default () => { headers: { Authorization: `Bearer ${store.state.token}`, + // Authorization: `Bearer sdfsdfsfsdf`, // 'Access-Control-Allow-Origin': '*' } @@ -58,7 +59,17 @@ export default () => { switch (errorNo) { case 401: customError = "Session expired" - vm1.$store.dispatch("RESET_STORE", null); + vm1.$store.dispatch("RESET_STORE", { + token: null, + data: null, + isUserLoggedIn: false, + id: null, + role: null, + // schoolId: null, + schoolToken: null, + schoolRole: null, + studentsData: [], + }); console.log("store is - ",vm1.$store.state) vm1.$router.push({ name: "Login" }); // vm1.$store.dispatch("Id", null); diff --git a/src/store/store.js b/src/store/store.js index 04fe8f7..fd502c5 100644 --- a/src/store/store.js +++ b/src/store/store.js @@ -28,6 +28,10 @@ export default new Vuex.Store({ }, // serve as the one and only way to change the state of the data in the state object mutations: { + RESET_STORE(state, defaultState) { + state = defaultState + // state.isUserLoggedIn = false + }, setToken(state, token) { state.token = token //state.isUserLoggedIn = !!(token) @@ -67,6 +71,11 @@ export default new Vuex.Store({ }, //Action methods are referred to as being "dispatched" actions: { + RESET_STORE({ + commit + }, defaultState) { + commit('RESET_STORE', defaultState) + }, setToken({ commit }, token) {