summaryrefslogtreecommitdiff
path: root/src/store
diff options
context:
space:
mode:
authorYoshie Muranaka <yoshiemuranaka@gmail.com>2020-06-01 19:44:23 +0300
committerDerick Montague <derick.montague@ibm.com>2020-06-10 22:19:44 +0300
commitc60d2e11286986a4ea9abd6e464857f22e7ad6ff (patch)
tree2d60a826a79f0d9a4e5e2e9ccef51236576919db /src/store
parent8e4b5c3f21fb3cacf4ee3c29817e31954cf146ea (diff)
downloadwebui-vue-c60d2e11286986a4ea9abd6e464857f22e7ad6ff.tar.xz
Fix duplicate navigation error
Adding a check to the 403 response api iterceptor before routing to the Unauthorized page. The router throws a NavigationDuplicated error when attempting to navigate to the same page. Signed-off-by: Yoshie Muranaka <yoshiemuranaka@gmail.com> Change-Id: Ib34d4d73a326440f609dd97d0dd677ff96b7b3a6
Diffstat (limited to 'src/store')
-rw-r--r--src/store/api.js7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/store/api.js b/src/store/api.js
index c8f1edae..4a8b8e80 100644
--- a/src/store/api.js
+++ b/src/store/api.js
@@ -19,6 +19,13 @@ api.interceptors.response.use(undefined, error => {
}
if (response.status == 403) {
+ if (router.history.current.name === 'unauthorized') {
+ // Check if current router location is unauthorized
+ // to avoid NavigationDuplicated errors.
+ // The router throws an error if trying to push to the
+ // same/current router location.
+ return;
+ }
router.push({ name: 'unauthorized' });
}