Commit 5b79088294c79270b5b4bd87ce89f7d99e08982e
1 parent
8c3acf4a97
Exists in
master
and in
3 other branches
clear token and role of superadmin while login to admin and teacher
Showing
1 changed file
with
4 additions
and
0 deletions
Show diff stats
src/event.js
1 | export default [{ | 1 | export default [{ |
2 | name: 'APP_LOGIN_SUCCESS', | 2 | name: 'APP_LOGIN_SUCCESS', |
3 | callback: function(e) { | 3 | callback: function(e) { |
4 | this.$router.push({ path: 'dashboard' }); | 4 | this.$router.push({ path: 'dashboard' }); |
5 | } | 5 | } |
6 | }, | 6 | }, |
7 | { | 7 | { |
8 | name: 'APP_LOGOUT', | 8 | name: 'APP_LOGOUT', |
9 | callback: function(e) { | 9 | callback: function(e) { |
10 | this.snackbar = { | 10 | this.snackbar = { |
11 | show: true, | 11 | show: true, |
12 | color: 'green', | 12 | color: 'green', |
13 | text: 'Logout successfully.' | 13 | text: 'Logout successfully.' |
14 | }; | 14 | }; |
15 | // console.log("roteeeeeeeeeeeeeee", this.$store.state.isUserLoggedIn) | 15 | // console.log("roteeeeeeeeeeeeeee", this.$store.state.isUserLoggedIn) |
16 | if (this.$store.state.role === "ADMIN") { | 16 | if (this.$store.state.role === "ADMIN") { |
17 | this.$store.dispatch('setToken', null) | 17 | this.$store.dispatch('setToken', null) |
18 | this.$store.dispatch('Id', null) | 18 | this.$store.dispatch('Id', null) |
19 | this.$store.dispatch('Role', null) | 19 | this.$store.dispatch('Role', null) |
20 | this.$store.dispatch('setSchoolToken', null) | ||
21 | this.$store.dispatch('setSchoolRole', null) | ||
20 | this.$router.replace({ path: '/' }); | 22 | this.$router.replace({ path: '/' }); |
21 | } else if (this.$store.state.schoolRole === "SUPERADMIN") { | 23 | } else if (this.$store.state.schoolRole === "SUPERADMIN") { |
22 | this.$store.dispatch('setSchoolToken', null) | 24 | this.$store.dispatch('setSchoolToken', null) |
23 | this.$store.dispatch('setSchoolRole', null) | 25 | this.$store.dispatch('setSchoolRole', null) |
24 | this.$router.replace({ path: '/' }); | 26 | this.$router.replace({ path: '/' }); |
25 | } else if (this.$store.state.role === "TEACHER") { | 27 | } else if (this.$store.state.role === "TEACHER") { |
26 | this.$store.dispatch('setToken', null) | 28 | this.$store.dispatch('setToken', null) |
27 | this.$store.dispatch('Id', null) | 29 | this.$store.dispatch('Id', null) |
28 | this.$store.dispatch('Role', null) | 30 | this.$store.dispatch('Role', null) |
31 | this.$store.dispatch('setSchoolToken', null) | ||
32 | this.$store.dispatch('setSchoolRole', null) | ||
29 | this.$router.replace({ path: '/' }); | 33 | this.$router.replace({ path: '/' }); |
30 | } | 34 | } |
31 | } | 35 | } |
32 | }, | 36 | }, |
33 | { | 37 | { |
34 | name: 'APP_CHANGE', | 38 | name: 'APP_CHANGE', |
35 | callback: function(e) { | 39 | callback: function(e) { |
36 | this.snackbar = { | 40 | this.snackbar = { |
37 | show: true, | 41 | show: true, |
38 | color: 'green', | 42 | color: 'green', |
39 | text: 'Logout successfully.' | 43 | text: 'Logout successfully.' |
40 | }; | 44 | }; |
41 | this.$router.replace({ | 45 | this.$router.replace({ |
42 | path: '/' | 46 | path: '/' |
43 | }); | 47 | }); |
44 | } | 48 | } |
45 | }, | 49 | }, |
46 | { | 50 | { |
47 | name: 'APP_PAGE_LOADED', | 51 | name: 'APP_PAGE_LOADED', |
48 | callback: function(e) {} | 52 | callback: function(e) {} |
49 | }, | 53 | }, |
50 | { | 54 | { |
51 | name: 'APP_AUTH_FAILED', | 55 | name: 'APP_AUTH_FAILED', |
52 | callback: function(e) { | 56 | callback: function(e) { |
53 | this.$router.push('/login'); | 57 | this.$router.push('/login'); |
54 | this.$message.error('Token has expired'); | 58 | this.$message.error('Token has expired'); |
55 | } | 59 | } |
56 | }, | 60 | }, |
57 | { | 61 | { |
58 | name: 'APP_BAD_REQUEST', | 62 | name: 'APP_BAD_REQUEST', |
59 | // @error api response data | 63 | // @error api response data |
60 | callback: function(msg) { | 64 | callback: function(msg) { |
61 | this.$message.error(msg); | 65 | this.$message.error(msg); |
62 | } | 66 | } |
63 | }, | 67 | }, |
64 | { | 68 | { |
65 | name: 'APP_ACCESS_DENIED', | 69 | name: 'APP_ACCESS_DENIED', |
66 | // @error api response data | 70 | // @error api response data |
67 | callback: function(msg) { | 71 | callback: function(msg) { |
68 | this.$message.error(msg); | 72 | this.$message.error(msg); |
69 | this.$router.push('/forbidden'); | 73 | this.$router.push('/forbidden'); |
70 | } | 74 | } |
71 | }, | 75 | }, |
72 | { | 76 | { |
73 | name: 'APP_RESOURCE_DELETED', | 77 | name: 'APP_RESOURCE_DELETED', |
74 | // @error api response data | 78 | // @error api response data |
75 | callback: function(msg) { | 79 | callback: function(msg) { |
76 | this.$message.success(msg); | 80 | this.$message.success(msg); |
77 | } | 81 | } |
78 | }, | 82 | }, |
79 | { | 83 | { |
80 | name: 'APP_RESOURCE_UPDATED', | 84 | name: 'APP_RESOURCE_UPDATED', |
81 | // @error api response data | 85 | // @error api response data |
82 | callback: function(msg) { | 86 | callback: function(msg) { |
83 | this.$message.success(msg); | 87 | this.$message.success(msg); |
84 | } | 88 | } |
85 | }, | 89 | }, |
86 | 90 | ||
87 | ]; | 91 | ]; |