Commit 1efb20890727582dd73137511098e2d0f7e929a3
1 parent
58e26b150d
Exists in
master
and in
2 other branches
changed interceptor
Showing
2 changed files
with
21 additions
and
1 deletions
Show diff stats
src/Services/http.js
... | ... | @@ -32,6 +32,7 @@ export default () => { |
32 | 32 | |
33 | 33 | headers: { |
34 | 34 | Authorization: `Bearer ${store.state.token}`, |
35 | + // Authorization: `Bearer sdfsdfsfsdf`, | |
35 | 36 | // 'Access-Control-Allow-Origin': '*' |
36 | 37 | |
37 | 38 | } |
... | ... | @@ -58,7 +59,17 @@ export default () => { |
58 | 59 | switch (errorNo) { |
59 | 60 | case 401: |
60 | 61 | customError = "Session expired" |
61 | - vm1.$store.dispatch("RESET_STORE", null); | |
62 | + vm1.$store.dispatch("RESET_STORE", { | |
63 | + token: null, | |
64 | + data: null, | |
65 | + isUserLoggedIn: false, | |
66 | + id: null, | |
67 | + role: null, | |
68 | + // schoolId: null, | |
69 | + schoolToken: null, | |
70 | + schoolRole: null, | |
71 | + studentsData: [], | |
72 | + }); | |
62 | 73 | console.log("store is - ",vm1.$store.state) |
63 | 74 | vm1.$router.push({ name: "Login" }); |
64 | 75 | // vm1.$store.dispatch("Id", null); | ... | ... |
src/store/store.js
... | ... | @@ -28,6 +28,10 @@ export default new Vuex.Store({ |
28 | 28 | }, |
29 | 29 | // serve as the one and only way to change the state of the data in the state object |
30 | 30 | mutations: { |
31 | + RESET_STORE(state, defaultState) { | |
32 | + state = defaultState | |
33 | + // state.isUserLoggedIn = false | |
34 | + }, | |
31 | 35 | setToken(state, token) { |
32 | 36 | state.token = token |
33 | 37 | //state.isUserLoggedIn = !!(token) |
... | ... | @@ -67,6 +71,11 @@ export default new Vuex.Store({ |
67 | 71 | }, |
68 | 72 | //Action methods are referred to as being "dispatched" |
69 | 73 | actions: { |
74 | + RESET_STORE({ | |
75 | + commit | |
76 | + }, defaultState) { | |
77 | + commit('RESET_STORE', defaultState) | |
78 | + }, | |
70 | 79 | setToken({ |
71 | 80 | commit |
72 | 81 | }, token) { | ... | ... |