From e6eb4a4b17e718911e13e15478aa45f755947436 Mon Sep 17 00:00:00 2001 From: yingfeng Date: Wed, 13 Nov 2024 14:38:21 -0500 Subject: [PATCH 1/3] 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; From 8d76967869bf8abaf904d0d035a43c5a00068df9 Mon Sep 17 00:00:00 2001 From: yingfeng Date: Mon, 2 Dec 2024 15:34:24 -0500 Subject: [PATCH 2/3] AMP-3469: add .prevent to @onclick for menu to prevent navigation with tag. --- src/components/navigation/Sidebar.vue | 2 +- src/main.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/navigation/Sidebar.vue b/src/components/navigation/Sidebar.vue index 9311aa9..8814b1a 100644 --- a/src/components/navigation/Sidebar.vue +++ b/src/components/navigation/Sidebar.vue @@ -18,7 +18,7 @@ > Date: Mon, 2 Dec 2024 15:43:44 -0500 Subject: [PATCH 3/3] AMP-3469: remove debug logs not needed --- src/components/navigation/Sidebar.vue | 2 -- src/router.js | 8 +++----- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/components/navigation/Sidebar.vue b/src/components/navigation/Sidebar.vue index 8814b1a..c5941cf 100644 --- a/src/components/navigation/Sidebar.vue +++ b/src/components/navigation/Sidebar.vue @@ -112,7 +112,6 @@ export default { }, methods: { routeToHome() { - console.log("routeToHome()"); const self = this; if ( self.$route.path === "/workflow/edit" && @@ -127,7 +126,6 @@ export default { } }, 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."); diff --git a/src/router.js b/src/router.js index 39f0ea9..88f6205 100644 --- a/src/router.js +++ b/src/router.js @@ -454,8 +454,8 @@ router.beforeEach(async (to, from, next) => { const { authorize } = to.meta; const currentUser = accountService.currentUserValue; - console.log("from: ", from, "\nto: ", to, "\nnext: ", next); - console.log("currentUser: ", currentUser); + console.log("router: from: ", from, "\nto: ", to, "\nnext: ", next); + console.log("router: currentUser: ", currentUser); if (env.getDisableAuth() == "true" || !authorize) { console.log("router: No auth needed.") @@ -468,16 +468,14 @@ 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) { store.state.isAuthenticated = false; store.commit("isAuthenticated"); - console.log("router: Auth token invalid!") + console.log("router: Auth token invalid! routing to login page.") 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;