하석형 하석형 04-07
250407 하석형 context path 변경 시 로그아웃 처리
@00cd81d46c0b79a0b6cb8b813a2df37779b11dc2
client/views/common/filters.js
--- client/views/common/filters.js
+++ client/views/common/filters.js
@@ -12,7 +12,7 @@
     // Context Path를 제외한 URL 생성
     logicalPath(path) {
         const contextPath = store.state.contextPath || '';
-        return (contextPath !== '/' && path.startsWith(contextPath)) ? path.slice(contextPath.length) : path;
+        return (contextPath !== '' && path.startsWith(contextPath)) ? path.slice(contextPath.length) : path;
     },
 
     // 아이디 정규식(5~20자의 영문 소문자, 숫자와 특수기호(_),(-)만 사용)
client/views/pages/adm/system/LoginPolicy/LoginPolicy.vue
--- client/views/pages/adm/system/LoginPolicy/LoginPolicy.vue
+++ client/views/pages/adm/system/LoginPolicy/LoginPolicy.vue
@@ -167,8 +167,8 @@
       if (!this.validation()) {
         return;
       }
-      // const isCheck = confirm("Context Path를 변경하면 로그아웃됩니다.\n계속하시겠습니까?");
-      const isCheck = confirm("Context Path를 변경하시겠습니까?");
+      const isCheck = confirm("Context Path를 변경하면 로그아웃됩니다.\n계속하시겠습니까?");
+      // const isCheck = confirm("Context Path를 변경하시겠습니까?");
       if (isCheck) {
         try {
           let ctx = { path: this.cntxtPth };
@@ -180,11 +180,11 @@
               storeCtx = '';
             }
             store.commit("setContextPath", storeCtx); // 캐시 초기화 요청을 보내기 위한 Context Path 정보 저장
-            // const cacheRes = await cacheReSet(); // 캐시 초기화
-            // alert(cacheRes.data.message);
-            // store.commit("setStoreReset"); // 캐시 초기화 후 Store 초기화
-            // window.location.reload(); // AppRouter 재실행을 위한 페이지 새로고침
-            window.location.href = `${storeCtx}/adm/main.page`;
+            const cacheRes = await cacheReSet(); // 캐시 초기화
+            store.commit("setStoreReset"); // 캐시 초기화 후 Store 초기화
+            store.commit("setContextPath", storeCtx); // 라우터 Context Path 정보 저장
+            window.location.href = `${storeCtx}/login.page`;
+            // window.location.href = `${storeCtx}/adm/main.page`;
           } else {
             alert(res.data.message);
           }
client/views/pages/login/Login.vue
--- client/views/pages/login/Login.vue
+++ client/views/pages/login/Login.vue
@@ -131,7 +131,17 @@
               alert("알 수 없는 로그인 방식입니다.");
               return;
           }
-          const url = this.restoreRedirect("redirect");
+
+          let url = this.restoreRedirect("redirect");
+          const ctx = store.state.contextPath;
+          if (ctx !== "") {
+            // redirect 값에서 Context Path 추가
+            url = this.$filters.ctxPath(url);
+          } else {
+            // redirect 값에서 기존 Context Path 제거
+            url = url.replace(/^\/[^\/]+/, ""); // 첫 번째 '/' 이후의 경로만 남김
+          }
+
           if (url != null && url != "") {
             if (url == this.$filters.ctxPath("/searchId.page") || url == this.$filters.ctxPath("/resetPswd.page")) {
               this.$router.push({ path: this.$filters.ctxPath("/main.page") });
Add a comment
List