Skip to content

Commit

Permalink
AMP-3469: add logs
Browse files Browse the repository at this point in the history
  • Loading branch information
yingfeng-iu committed Nov 13, 2024
1 parent cf65ae5 commit e6eb4a4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
8 changes: 8 additions & 0 deletions src/components/navigation/Sidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ export default {
},
methods: {
routeToHome() {
console.log("routeToHome()");
const self = this;
if (
self.$route.path === "/workflow/edit" &&
Expand All @@ -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.");
Expand All @@ -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;
Expand All @@ -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;
}
}
Expand Down
6 changes: 4 additions & 2 deletions src/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
Expand All @@ -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;
Expand Down

0 comments on commit e6eb4a4

Please sign in to comment.