summaryrefslogtreecommitdiff
path: root/src/store/api.js
diff options
context:
space:
mode:
authorSukanya Pandey <sukapan1@in.ibm.com>2020-10-08 18:17:39 +0300
committerDerick Montague <derick.montague@ibm.com>2020-10-21 00:34:04 +0300
commitdd6aa0aa8f12426c681f5991f2e9a21b379e86c3 (patch)
tree3297232b18559392eb193068022ce6d99412e227 /src/store/api.js
parenta11cedb53a540b7455a8169b74b62009b5982b7d (diff)
downloadwebui-vue-dd6aa0aa8f12426c681f5991f2e9a21b379e86c3.tar.xz
Show error toast notification on unauthorized access
-When 403 status code which is an unauthorized access occured -show error toast notification. Signed-off-by: Sukanya Pandey <sukapan1@in.ibm.com> Change-Id: I55fa7052073f87f28c3584b68fd4e84247a4237e
Diffstat (limited to 'src/store/api.js')
-rw-r--r--src/store/api.js14
1 files changed, 4 insertions, 10 deletions
diff --git a/src/store/api.js b/src/store/api.js
index ac1b2e36..77d94329 100644
--- a/src/store/api.js
+++ b/src/store/api.js
@@ -1,6 +1,4 @@
import Axios from 'axios';
-import router from '@/router';
-
//Do not change store import.
//Exact match alias set to support
//dotenv customizations.
@@ -23,14 +21,10 @@ 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' });
+ // Check if action is unauthorized.
+ // Toast error message will appear on screen
+ // when the action is unauthorized.
+ store.commit('global/setUnauthorized');
}
return Promise.reject(error);