api.js (8263d85c4f97cbf22639054412ea0323251de0f7) | api.js (dd6aa0aa8f12426c681f5991f2e9a21b379e86c3) |
---|---|
1import Axios from 'axios'; | 1import Axios from 'axios'; |
2import router from '@/router'; 3 | |
4//Do not change store import. 5//Exact match alias set to support 6//dotenv customizations. 7import store from '../store'; 8 9const api = Axios.create({ 10 withCredentials: true 11}); --- 6 unchanged lines hidden (view full) --- 18 if (response.config.url != '/login') { 19 window.location = '/login'; 20 // Commit logout to remove XSRF-TOKEN cookie 21 store.commit('authentication/logout'); 22 } 23 } 24 25 if (response.status == 403) { | 2//Do not change store import. 3//Exact match alias set to support 4//dotenv customizations. 5import store from '../store'; 6 7const api = Axios.create({ 8 withCredentials: true 9}); --- 6 unchanged lines hidden (view full) --- 16 if (response.config.url != '/login') { 17 window.location = '/login'; 18 // Commit logout to remove XSRF-TOKEN cookie 19 store.commit('authentication/logout'); 20 } 21 } 22 23 if (response.status == 403) { |
26 if (router.history.current.name === 'unauthorized') { 27 // Check if current router location is unauthorized 28 // to avoid NavigationDuplicated errors. 29 // The router throws an error if trying to push to the 30 // same/current router location. 31 return; 32 } 33 router.push({ name: 'unauthorized' }); | 24 // Check if action is unauthorized. 25 // Toast error message will appear on screen 26 // when the action is unauthorized. 27 store.commit('global/setUnauthorized'); |
34 } 35 36 return Promise.reject(error); 37}); 38 39export default { 40 get(path) { 41 return api.get(path); --- 35 unchanged lines hidden --- | 28 } 29 30 return Promise.reject(error); 31}); 32 33export default { 34 get(path) { 35 return api.get(path); --- 35 unchanged lines hidden --- |