mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2024-11-24 02:59:16 +08:00
fix: 解决登录情况下,输入任意路由跳转到安全入口的问题 (#954)
This commit is contained in:
parent
eea28e8481
commit
7d4a8782d8
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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();
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user