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
diff --git a/src/store/api.js b/src/store/api.js
index ac1b2e3..77d9432 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 @@
}
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);