diff --git a/frontend/src/api/helper/check-status.ts b/frontend/src/api/helper/check-status.ts index d05950b3c..1c18cc2a3 100644 --- a/frontend/src/api/helper/check-status.ts +++ b/frontend/src/api/helper/check-status.ts @@ -13,6 +13,7 @@ export const checkStatus = (status: number, msg: string): void => { MsgError(msg ? msg : i18n.global.t('commons.res.notFound')); break; case 403: + globalStore.setLogStatus(false); router.replace({ name: 'entrance', params: { code: globalStore.entrance } }); MsgError(msg ? msg : i18n.global.t('commons.res.forbidden')); break; diff --git a/frontend/src/api/index.ts b/frontend/src/api/index.ts index fd58611ee..2629a98e3 100644 --- a/frontend/src/api/index.ts +++ b/frontend/src/api/index.ts @@ -42,6 +42,7 @@ class RequestHttp { globalStore.setCsrfToken(response.headers['x-csrf-token']); } if (data.code == ResultEnum.OVERDUE || data.code == ResultEnum.FORBIDDEN) { + globalStore.setLogStatus(false); router.push({ name: 'entrance', params: { code: globalStore.entrance }, @@ -49,6 +50,7 @@ class RequestHttp { return Promise.reject(data); } if (data.code == ResultEnum.EXPIRED) { + globalStore.setLogStatus(false); router.push({ name: 'Expired' }); return data; } diff --git a/frontend/src/routers/index.ts b/frontend/src/routers/index.ts index 762200c2b..72e04a2ec 100644 --- a/frontend/src/routers/index.ts +++ b/frontend/src/routers/index.ts @@ -11,10 +11,23 @@ const axiosCanceler = new AxiosCanceler(); router.beforeEach((to, from, next) => { NProgress.start(); axiosCanceler.removeAllPending(); + const globalStore = GlobalStore(); + + if (to.name === 'entrance' && globalStore.isLogin) { + if (to.params.code === globalStore.entrance) { + next({ + name: 'entrance', + params: { code: globalStore.entrance }, + }); + NProgress.done(); + return; + } + next({ name: '404' }); + NProgress.done(); + return; + } if (!to.matched.some((record) => record.meta.requiresAuth)) return next(); - - const globalStore = GlobalStore(); if (!globalStore.isLogin) { next({ name: 'entrance', @@ -23,6 +36,7 @@ router.beforeEach((to, from, next) => { NProgress.done(); return; } + return next(); });