From 3d1e6a2af00d76a4f1fa84cf480ff38cb4d1f879 Mon Sep 17 00:00:00 2001 From: kimjhjjang Date: Tue, 8 Nov 2022 15:00:36 +0900 Subject: [PATCH] =?UTF-8?q?router=20Store=20Login=20Path=20=ED=99=95?= =?UTF-8?q?=EC=9D=B8=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/modules/login/store/index.js | 40 +++++++++++++---------- frontend/src/router.js | 15 ++++----- 2 files changed, 28 insertions(+), 27 deletions(-) diff --git a/frontend/src/modules/login/store/index.js b/frontend/src/modules/login/store/index.js index d7cb2b0..0d5966b 100644 --- a/frontend/src/modules/login/store/index.js +++ b/frontend/src/modules/login/store/index.js @@ -3,29 +3,31 @@ const state = { isLogin: false, isErrorPage: false, isAuthChk: false, - userId:null, - userNm:null, + userId: null, + userNm: null, pwd: null, rootUrl: null, menuUrls: [], authToken: null, beforeUrl: null, isLoading: false, + loginPathUrl: null, }; const getters = { - getToken: state => state.token, - isLogin: state => state.isLogin, - isErrorPage: state => state.isErrorPage, - isAuthChk: state => state.isAuthChk, - userId: state => state.userId, - userNm: state => state.userNm, - getPwd: state => state.pwd, - getRootUrl: state => state.rootUrl, - getMenuUrls: state => state.menuUrls, - getAuthToken: state => state.authToken, - getBeforeUrl: state => state.beforeUrl, - isLoading: state => state.isLoading, + getToken: (state) => state.token, + isLogin: (state) => state.isLogin, + isErrorPage: (state) => state.isErrorPage, + isAuthChk: (state) => state.isAuthChk, + userId: (state) => state.userId, + userNm: (state) => state.userNm, + getPwd: (state) => state.pwd, + getRootUrl: (state) => state.rootUrl, + getMenuUrls: (state) => state.menuUrls, + getAuthToken: (state) => state.authToken, + getBeforeUrl: (state) => state.beforeUrl, + isLoading: (state) => state.isLoading, + getLoginPathUrl: (state) => state.loginPathUrl, }; const mutations = { @@ -70,16 +72,18 @@ const mutations = { }, isLoading: (state, value) => { state.isLoading = value; - } + }, + setLoginPathUrl: (state, value) => { + state.loginPathUrl = value; + }, }; -const actions = { -}; +const actions = {}; export default { namespaced: true, state, getters, mutations, - actions + actions, }; diff --git a/frontend/src/router.js b/frontend/src/router.js index 8bcf82a..57e3517 100644 --- a/frontend/src/router.js +++ b/frontend/src/router.js @@ -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);