Skip to content

Commit 2f1ec6c

Browse files
committed
fixed token expired bug with login page.
1 parent ed1729f commit 2f1ec6c

File tree

3 files changed

+29
-19
lines changed

3 files changed

+29
-19
lines changed

src/App.vue

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
<div id="app">
7979
<load-ing :active.sync="isLoading" :can-cancel="true" :is-full-page="true"></load-ing>
8080

81-
<b-navbar toggleable="lg" type="dark" variant="white" class="navStyle" v-if="showIcon" sticky>
81+
<b-navbar toggleable="lg" type="dark" variant="white" class="navStyle" v-if="getIsLoggedOut" sticky>
8282
<b-navbar-brand href="#">
8383
<a href="#" @click="route('dashboard')">
8484
<img src="./assets/Entity_full.png" alt="" style="height: 5vh; opacity: 80%" />
@@ -107,7 +107,7 @@
107107
<i class="fas fa-book-open f-36" style=" color: grey"></i>
108108
</b-nav-item>
109109

110-
<b-nav-item-dropdown right v-if="showIcon" title="Profile">
110+
<b-nav-item-dropdown right v-if="getIsLoggedOut" title="Profile">
111111
<template #button-content>
112112
<i class="fas fa-user-circle f-36" style="color: grey"></i>
113113
</template>
@@ -300,7 +300,7 @@ import { mapActions, mapMutations, mapGetters, mapState } from "vuex";
300300
export default {
301301
computed: {
302302
...mapGetters("playgroundStore", ["userDetails", "getSelectedOrg"]),
303-
...mapGetters("mainStore", ["getSelectedService", "getAllServices"]),
303+
...mapGetters("mainStore", ["getSelectedService", "getAllServices", 'getIsLoggedOut']),
304304
...mapState({
305305
showMainSideNavBar: (state) => state.mainStore.showMainSideNavBar,
306306
selectedDashboard: (state) => state.globalStore.selectedDashboard,
@@ -324,7 +324,6 @@ export default {
324324
return {
325325
isLoading: false,
326326
collapsed: true,
327-
showIcon: true,
328327
isSidebarCollapsed: true,
329328
schema_page: 1,
330329
authRoutes: ["register", "PKIIdLogin"],
@@ -336,7 +335,8 @@ export default {
336335
mounted() {
337336
this.$root.$on("clearAppData", () => {
338337
this.authToken = null;
339-
this.showIcon = false;
338+
// this.showIcon = false;
339+
this.setIsLoggedOut(false)
340340
});
341341
342342
this.$root.$on("recomputeParseAuthTokenEvent", () => {
@@ -351,7 +351,8 @@ export default {
351351
if (localStorage.getItem("user")) {
352352
const usrStr = localStorage.getItem("user");
353353
this.user = JSON.parse(usrStr);
354-
this.showIcon = true;
354+
// this.showIcon = true;
355+
this.setIsLoggedOut(true)
355356
}
356357
if (localStorage.getItem("selectedOrg")) {
357358
const selectedOrgId = localStorage.getItem("selectedOrg");
@@ -372,7 +373,7 @@ export default {
372373
},
373374
methods: {
374375
...mapActions("mainStore", ["fetchAppsListFromServer", "fetchServicesList"]),
375-
...mapMutations("mainStore", ["resetMainStore"]),
376+
...mapMutations("mainStore", ["resetMainStore", "setIsLoggedOut"]),
376377
...mapActions("playgroundStore", [
377378
"insertAschema",
378379
"insertAcredential",
@@ -406,9 +407,9 @@ export default {
406407
return "https://api.dicebear.com/7.x/identicon/svg?seed=" + name;
407408
},
408409
logoutAll() {
409-
this.showIcon = false;
410+
// this.showIcon = false;
411+
this.setIsLoggedOut(false)
410412
if (this.$route.path !== '/login') this.$router.push('/login')
411-
412413
this.logout();
413414
},
414415
@@ -442,20 +443,13 @@ export default {
442443
try {
443444
this.authToken = localStorage.getItem("authToken");
444445
if (this.authToken) {
445-
this.showIcon = true;
446-
// this.isLoading = true;
447-
// await this.fetchAppsListFromServer();
448-
// await this.fetchServicesList()
449-
446+
this.setIsLoggedOut(true)
450447
this.$router.push("dashboard").then(() => { this.$router.go(0) });
451-
452-
// this.isLoading = false;
453448
} else {
454449
throw new Error("No auth token")
455450
}
456451
} catch (e) {
457-
this.showIcon = false
458-
// this.isLoading = false;
452+
this.setIsLoggedOut(false)
459453
this.notifyErr(`Error: ${e.message}`);
460454
}
461455
@@ -615,6 +609,7 @@ export default {
615609
localStorage.removeItem("selectedOrg");
616610
this.resetStore();
617611
this.resetMainStore();
612+
this.$router.go()
618613
},
619614
620615
formattedAppName(appName) {

src/router.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import Router from 'vue-router'
33
import fetch from 'node-fetch'
44
import config from './config'
55
import store from './store'
6-
76
const Home = () => import('./views/Home.vue');
87
const PKIIdLogin = () => import('./views/PKIIdLogin.vue')
98
const MainDashboard = () => import('./views/Dashboard.vue')
@@ -219,6 +218,10 @@ router.beforeEach(async (to, from, next) => {
219218
})
220219
}
221220
} else {
221+
console.log(to.path)
222+
if (to.path === '/studio/login') {
223+
store.commit('mainStore/setIsLoggedOut', false)
224+
}
222225
next()
223226
}
224227
})

src/store/mainStore.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ const mainStore = {
2727
didList: [],
2828
onchainconfigs: [],
2929
onChainConfig: {},
30+
isLoggedOut: false,
3031
widgetConfig: {
3132

3233
},
@@ -39,6 +40,9 @@ const mainStore = {
3940
kycCredits: []
4041
},
4142
getters: {
43+
getIsLoggedOut: (state) => {
44+
return state.isLoggedOut
45+
},
4246
getAdminMembersgetter: (state) => {
4347
return state.adminMembers
4448
},
@@ -127,6 +131,14 @@ const mainStore = {
127131
}
128132
},
129133
mutations: {
134+
setIsLoggedOut: (state, payload = false) => {
135+
state.isLoggedOut = payload;
136+
// localStorage.removeItem("authToken");
137+
localStorage.removeItem("user");
138+
localStorage.removeItem("credentials");
139+
localStorage.removeItem("userData");
140+
localStorage.removeItem("selectedOrg")
141+
},
130142
setAuthToken(state, payload) {
131143
console.log(state.namespaced)
132144
localStorage.setItem("authToken", payload);

0 commit comments

Comments
 (0)