router Store Login Path 확인 설정

This commit is contained in:
kimjhjjang
2022-11-08 15:00:36 +09:00
parent 4d43e04630
commit 3d1e6a2af0
2 changed files with 28 additions and 27 deletions

View File

@@ -54,8 +54,8 @@ const router = new Router({
...profileRoutes,
...mntrngRoutes,
...riskmgtRoutes,
...monthRoutes,
...homeMgtRoutes,
...monthRoutes,
//{path: '*', name: 'error404'}
],
},
@@ -66,11 +66,8 @@ const router = new Router({
router.beforeEach((to, from, next) => {
const isPublic = to.matched.some((record) => record.meta.public);
const loggedIn = !!tokenSvc.getToken();
console.log(isPublic);
console.log(loggedIn);
console.log(to);
if (!isPublic && !loggedIn) {
console.log('1');
store.commit('login/setLoginPathUrl', 1);
return next('/login');
} else {
var nextUrl = to.fullPath;
@@ -201,7 +198,7 @@ router.beforeEach((to, from, next) => {
fromUrl == '/view/login/resetPassword' ||
fromUrl == '/view/login/updatePassword'
) {
console.log('2');
store.commit('login/setLoginPathUrl', 2);
return next('/login');
}
// store.commit("login/isErrorPage", true);
@@ -214,7 +211,7 @@ router.beforeEach((to, from, next) => {
nextUrl == '/view/login/updatePassword'
) {
if (fromUrl != '/login') {
console.log('3');
store.commit('login/setLoginPathUrl', 3);
return next('/login');
}
}
@@ -222,7 +219,7 @@ router.beforeEach((to, from, next) => {
if (nextUrl == '/') {
const rootUrl = store.getters['login/getRootUrl'];
if (rootUrl == null) {
console.log('4');
store.commit('login/setLoginPathUrl', 4);
return next('/login');
}
return next(rootUrl);
@@ -231,7 +228,7 @@ router.beforeEach((to, from, next) => {
if (nextUrl == '/login' && loggedIn) {
const rootUrl = store.getters['login/getRootUrl'];
if (rootUrl == null) {
console.log('5');
store.commit('login/setLoginPathUrl', 5);
return next('/login');
}
return next(rootUrl);