@@ -45,24 +44,16 @@
diff --git a/src/router.js b/src/router.js
index b8c146dc..a12adb51 100644
--- a/src/router.js
+++ b/src/router.js
@@ -478,10 +478,11 @@ router.beforeEach(async (to, from, next) => {
const currentUser = accountService.currentUserValue;
if (env.getDisableAuth() == "true" || !authorize) {
+ console.log("router: No auth needed.")
return next();
} else if (!currentUser) {
- console.log("Current user not logged in yet.");
- // not logged in so redirect to login page with the return url
+ console.log("router: Current user not logged in yet.");
+ // not logged in so redirect to access-denied page with login link and with the return url
return router.push({ path: "/access-denied", query: { returnUrl: to.path }});
} else {
// TODO, below API call is to validate auth token, in case the locally stored one is compromised;
@@ -491,6 +492,7 @@ router.beforeEach(async (to, from, next) => {
// return next();
router.app.$store.state.isAuthenticated = false;
router.app.$store.commit("isAuthenticated");
+ console.log("router: Auth token invalid!")
return next({ path: "/account/login", query: { returnUrl: to.path } });
} else {
router.app.$store.state.isAuthenticated = true;
@@ -498,7 +500,7 @@ router.beforeEach(async (to, from, next) => {
// let acActions = router.app.$store.state.acActions;
let acActions = store.state.acActions;
let acIsAdmin = store.state.acIsAdmin;
- console.log("initPermissions = ", acActions," isAdmin = ", acIsAdmin);
+ console.log("router: initPermissions = ", acActions," isAdmin = ", acIsAdmin);
if (acActions.includes(action) || acIsAdmin) {
console.log(currentUser.username + " can perform action " + action);
return next();
diff --git a/src/service/account-service.js b/src/service/account-service.js
index f36ba2ba..a96479df 100644
--- a/src/service/account-service.js
+++ b/src/service/account-service.js
@@ -2,6 +2,11 @@ import BaseService from './base-service.js';
const currentUser = JSON.parse(localStorage.getItem('currentUser'));
const baseService = new BaseService();
+
+// TODO
+// API calls for user registration & reset password etc should not use post_auth as
+// these APIs do not require authentication; instead just use plain baseService.post
+
function sendRegisterRequest(username, firstName, lastName, pswd, email) {
const url = `/account/register`;
return baseService.post_auth(url,
From 6a2972ff831f56bc7e1bc58bbc7c9012acc40145 Mon Sep 17 00:00:00 2001
From: yingfeng
Date: Wed, 15 Nov 2023 09:23:52 -0500
Subject: [PATCH 3/5] AMP-2826/2226 - add space for resend on ForgotPassword
page - add logs to router
---
src/components/account/ForgotPassword.vue | 4 ++--
src/router.js | 3 ++-
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/components/account/ForgotPassword.vue b/src/components/account/ForgotPassword.vue
index 4e12bedf..43763b71 100644
--- a/src/components/account/ForgotPassword.vue
+++ b/src/components/account/ForgotPassword.vue
@@ -47,8 +47,8 @@
diff --git a/src/router.js b/src/router.js
index a12adb51..50f25d8d 100644
--- a/src/router.js
+++ b/src/router.js
@@ -36,7 +36,6 @@ var router = new Router({
name: "home",
component: HomePage,
meta: {
- // authorize: [],
helpUrl: env.getEnv("VUE_APP_DOC_AMP_USER_GUIDE"),
},
},
@@ -477,6 +476,8 @@ router.beforeEach(async (to, from, next) => {
const { authorize } = to.meta;
const currentUser = accountService.currentUserValue;
+ console.log("from: ", from, "\nto: ", to, "\nnext: ", next);
+
if (env.getDisableAuth() == "true" || !authorize) {
console.log("router: No auth needed.")
return next();
From 50232cb020a05c1174082897bc7d909d6c89a265 Mon Sep 17 00:00:00 2001
From: yingfeng