From e6eb4a4b17e718911e13e15478aa45f755947436 Mon Sep 17 00:00:00 2001 From: yingfeng Date: Wed, 13 Nov 2024 14:38:21 -0500 Subject: [PATCH] AMP-3469: add logs --- src/components/navigation/Sidebar.vue | 8 ++++++++ src/router.js | 6 ++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/components/navigation/Sidebar.vue b/src/components/navigation/Sidebar.vue index a772708..9311aa9 100644 --- a/src/components/navigation/Sidebar.vue +++ b/src/components/navigation/Sidebar.vue @@ -112,6 +112,7 @@ export default { }, methods: { routeToHome() { + console.log("routeToHome()"); const self = this; if ( self.$route.path === "/workflow/edit" && @@ -121,10 +122,12 @@ export default { "Workflow editor session is active. Please click on done button before leaving the page." ); } else { + console.log("routing to home"); self.$router.push("/"); } }, routeTo(menu, data) { + console.log("routeTo()"); const self = this; if (self.$route.path === "/workflow/edit" && localStorage.getItem("activeWorkflowSession")) { alert("Workflow editor session is active. Please click on done button before leaving the page."); @@ -135,6 +138,7 @@ export default { self.$router.push(`${menu.url}/${data.id}`); } } else { + console.log("routing to menu"); self.$router.push(`${menu.url}`).catch(error => { if (error.name !== 'NavigationDuplicated') { throw error; @@ -144,15 +148,19 @@ export default { }, resolvePermissions(keys) { if(this.acIsAdmin) { + console.log("resolvePermissions: is Admin", keys); return false; } else { if(Array.isArray(keys) && keys.length > 0) { + console.log("resolvePermissions: keys is array", keys); return keys.map(key => { return this.acActions.indexOf(key) < 0; }).reduce((acc, current) => acc && current, true); } else if(typeof keys === "string") { + console.log("resolvePermissions: keys is string", keys); return this.acActions.indexOf(keys) < 0; } else { + console.log("resolvePermissions: permission denied", keys); return true; } } diff --git a/src/router.js b/src/router.js index c52ded4..39f0ea9 100644 --- a/src/router.js +++ b/src/router.js @@ -458,7 +458,7 @@ router.beforeEach(async (to, from, next) => { console.log("currentUser: ", currentUser); if (env.getDisableAuth() == "true" || !authorize) { - console.log("router: No auth needed.") + console.log("router: No auth needed.") return next(); } else if (!currentUser) { console.log("router: Current user not logged in yet."); @@ -468,14 +468,16 @@ router.beforeEach(async (to, from, next) => { // TODO // below API call is to validate the auth token before new page is loaded, in case the current login has expired; // there should be better way to achieve this without making such extra API call + console.log("validating user"); var success = await accountService.validate(); + console.log("success = " + success); if (!success) { - // return next(); store.state.isAuthenticated = false; store.commit("isAuthenticated"); console.log("router: Auth token invalid!") return next({ path: "/account/login", query: { returnUrl: to.path } }); } else { + console.log("checking permission"); store.state.isAuthenticated = true; let action = authorize.actionType + "-" + authorize.targetType; // let acActions = router.app.$store.state.acActions;