yjryu / KERIS star
류윤주 류윤주 2023-11-29
231129 류윤주 권한에 따른 접근 1차 커밋
@87fd272fb067b6ef341c34c8e62912889bd62db6
client/views/layout/Menu.vue
--- client/views/layout/Menu.vue
+++ client/views/layout/Menu.vue
@@ -36,10 +36,11 @@
                 <ul class="main-menu main-menu-1">
                     <li v-for="menuItem in menuItems" :key="menuItem.text" :class="{ 'active': menuItem.isHovered }"
                         @mouseover="menuItem.isHovered = true" @mouseout="menuItem.isHovered = false">
-                        <router-link :to="menuItem.link">{{ menuItem.text }}</router-link>
+                        <router-link v-if="shouldRenderMenuItem(menuItem)" :to="menuItem.link">{{ menuItem.text
+                        }}</router-link>
                         <ul class="sub-menu sub-menu-1">
                             <li v-for="subMenuItem in menuItem.subMenu" :key="subMenuItem.text" @click="navClose(menuItem)">
-                                <router-link :to="subMenuItem.link">{{ subMenuItem.text }}</router-link>
+                                <router-link v-if="shouldRenderSubMenuItem(subMenuItem)" :to="subMenuItem.link">{{ subMenuItem.text }}</router-link>
                             </li>
                         </ul>
                     </li>
@@ -50,6 +51,7 @@
 </template>
 
 <script>
+import { useStore } from "vuex";
 export default {
     data() {
         return {
@@ -101,7 +103,8 @@
                         { text: "매칭 관리", link: "/MatchingManager.page" }
                     ]
                 }
-            ]
+            ],
+            store: useStore(),
         };
     },
     methods: {
@@ -118,7 +121,23 @@
             menuItem.isExpanded = false;
             this.check = false;
         },
-
+        shouldRenderMenuItem(menuItem) {
+            //해당 메뉴 항목이 로그인 상태에 따라 렌더링되어야 하는지 확인하는 로직
+            if (menuItem.text === "마이페이지") {
+                return this.store.state.loginUser != null;
+            }
+            // 다른 메뉴 항목은 항상 표시
+            return true;
+        },
+        shouldRenderSubMenuItem(subMenuItem) {
+            // 해당 서브 메뉴 항목이 로그인 상태에 따라 렌더링되어야 하는지 확인하는 로직
+            if (subMenuItem.text === "매칭 관리") {
+                // '매칭 관리' 항목은 'company'로 로그인한 경우에만 표시
+                return this.store.state.loginUser.user_auth === 'company';
+            }
+            // 다른 서브 메뉴 항목은 항상 표시
+            return true;
+        }
     },
     watch: {
 
client/views/pages/App.vue
--- client/views/pages/App.vue
+++ client/views/pages/App.vue
@@ -1,5 +1,5 @@
 <template>
-   <div v-if="isAdminPage" class="admin-wrap" >
+   <div v-if="isAdminPage" class="admin-wrap">
       <div :class="layoutClass">
          <AdminHeader v-show="isLogin" :mngrId="mngrInfo" @updateIsLogin="isLogin = $event"></AdminHeader>
          <AdminMenu v-show="isLogin"></AdminMenu>
@@ -16,6 +16,19 @@
       </div>
       <Footer></Footer>
    </div>
+   <!-- <div v-show="isModalOpen" class="modal-wrapper">
+      <div class="modal-container">
+         <p>
+            해당글은 정회원에게 공개된 게시물 입니다.
+            (준회원은 가입 승인 이후 열람 가능하며,
+            비회원은 회원가입이 필요합니다.)
+         </p>
+         <div class="modal-end">
+            <button class="dark-gray-btn mgl5" @click="closeModal()">닫기</button>
+            <button class="blue-btn" @click="loginMove">로그인</button>
+         </div>
+      </div>
+   </div> -->
 </template>
 
 <script>
@@ -41,7 +54,9 @@
             mngr_id: null,
          },
          store: useStore(),
-         screenType: 'large', 
+         screenType: 'large',
+         // 모달창 오픈 상태
+         isModalOpen: false,
       };
    },
    created() {
@@ -49,6 +64,18 @@
       this.debouncedHandleResize = debounce(this.handleResize, 200); // 200ms 디바운스
    },
    methods: {
+      openModal: function () {
+         this.isModalOpen = true;
+      },
+
+      closeModal: function () {
+         this.isModalOpen = false;
+         console.log("1");
+         this.modalType = null;
+         console.log("2");
+      },
+
+
       // 로그인
       updateIsLogin: function (boolean) {
          console.log("newValue : ", newValue);
@@ -111,7 +138,7 @@
          });
       },
       // 반응형을 위한 핸들러
-      handleResize() {
+      handleResize: function () {
          const screenWidth = window.innerWidth;
          if (screenWidth <= 480) {
             this.screenType = 'small';
@@ -122,6 +149,11 @@
          }
          console.log('isLargeScreen:', this.screenType); // 값 확인
       },
+
+      loginMove: function () {
+         this.$router.push('/Login.page');
+         this.isModalOpen = false
+      }
    },
    watch: {
 
@@ -183,15 +215,32 @@
             this.loginUserSelectOne(function (store) {
                //로그인 유무(로그인 정보가 있으면 True, 없으면 False)
                let isLogin = (store.loginUser != null && store.loginUser['user_id'] != null);
+               const authenticationState = store.loginUser;
+               const { authorization } = to.meta;
+               const nonMember = authenticationState == null ? '비회원' : '회원'
+
                //로그인 상태 일 때
                if (isLogin == true) {
+                  const memberType = authenticationState.create_account_approval === 'Y' ? '정회원' : '준회원';
+                  const memberTypeDetail = memberType === '정회원' ? (authenticationState.user_auth === 'common' ? '일반 정회원' : '기업 정회원') : '준회원';
+                  console.log("::::", memberTypeDetail);
                   //로그인 페이지 이동은 못하게 함
                   if (to.path == '/login.page') {
                      next(false);
                   } else {//로그인 페이지 이 외의 페이지들을 이동 가능하게 함
+                     if (!authorization.includes(memberTypeDetail)) {
+                        // 권한이 없는 유저는 not-found 페이지로 보낸다.
+                        next({ path: "/" });
+                     }
                      next();
                   }
                } else {//로그인 상태가 아닐 때
+                  // 로그인 상태가 아니면 권한이 없는게 있어 넣어줘야함
+                  if (!authorization.includes(nonMember)) {
+                     if (nonMember == '비회원') {
+                       alert(' 해당글은 정회원에게 공개된 게시물 입니다. (준회원은 가입 승인 이후 열람 가능하며, 비회원은 회원가입이 필요합니다.)')
+                     }  next();
+                  }
                   next();
                }
             });
client/views/pages/AppRouter.js
--- client/views/pages/AppRouter.js
+++ client/views/pages/AppRouter.js
@@ -74,27 +74,27 @@
 
 const routes = [
   /* 메인화면 */
-  { path: "/", name: "Main", component: Main },
-  { path: "/Data.page", name: "Data", component: Data },
-  { path: "/Matching.page", name: "Matching", component: Matching },
-  { path: "/Login.page", name: "Login", component: Login },
-  { path: "/Join.page", name: "Join", component: Join },
-  { path: "/Joinsub.page", name: "Joinsub", component: Joinsub },
-  { path: "/Introduction.page", name: "Introduction", component: Introduction },
-  { path: "/Technology.page", name: "Technology", component: Technology },
-  { path: "/Notice.page", name: "Notice", component: Notice },
-  { path: "/Info.page", name: "Info", component: Info },
-  { path: "/Guide.page", name: "Guide", component: Guide },
-  { path: "/Infosub.page", name: "Infosub", component: Infosub },
-  { path: "/News.page", name: "News", component: News },
-  { path: "/DataDtali.page", name: "DataDtali", component: DataDtali },
-  { path: "/NoticeOne.page", name: "NoticeOne", component: NoticeOne },
-  { path: "/Wgcommunity.page", name: "Wgcommunity", component: Wgcommunity },
-  { path: "/WgcommunityOne.page", name: "WgcommunityOne", component: WgcommunityOne,},
-  { path: "/MatchingOne.page", name: "MatchingOne", component: MatchingOne },
-  { path: "/userIDsearch.page", name: "userIDsearch", component: userIDsearch },
-  { path: "/TechnologyOne.page", name: "TechnologyOne", component: TechnologyOne,},
-  { path: "/MatchingManager.page", name: "MatchingManager", component: MatchingManager,},
+  { path: "/", name: "Main", component: Main, meta:{authorization:["비회원","준회원","일반 정회원","기업 정회원"]}},
+  { path: "/Data.page", name: "Data", component: Data, meta:{authorization:["비회원","준회원","일반 정회원","기업 정회원"]}  },
+  { path: "/Matching.page", name: "Matching", component: Matching, meta:{authorization:["비회원","준회원","일반 정회원","기업 정회원"]} },
+  { path: "/Login.page", name: "Login", component: Login, meta:{authorization:["비회원","준회원","일반 정회원","기업 정회원"]}  },
+  { path: "/Join.page", name: "Join", component: Join, meta:{authorization:["비회원","준회원","일반 정회원","기업 정회원"]} },
+  { path: "/Joinsub.page", name: "Joinsub", component: Joinsub, meta:{authorization:["비회원","준회원","일반 정회원","기업 정회원"]} },
+  { path: "/Introduction.page", name: "Introduction", component: Introduction, meta:{authorization:["비회원","준회원","일반 정회원","기업 정회원"]} },
+  { path: "/Technology.page", name: "Technology", component: Technology, meta:{authorization:["비회원","준회원","일반 정회원","기업 정회원"]} },
+  { path: "/Notice.page", name: "Notice", component: Notice, meta:{authorization:["비회원","준회원","일반 정회원","기업 정회원"]} },
+  { path: "/Info.page", name: "Info", component: Info,meta:{authorization:["준회원","일반 정회원","기업 정회원"]} },
+  { path: "/Guide.page", name: "Guide", component: Guide, meta:{authorization:["비회원","준회원","일반 정회원","기업 정회원"]}},
+  { path: "/Infosub.page", name: "Infosub", component: Infosub,meta:{authorization:["일반 정회원","기업 정회원"]} },
+  { path: "/News.page", name: "News", component: News, meta:{authorization:["비회원","준회원","일반 정회원","기업 정회원"]} },
+  { path: "/DataDtali.page", name: "DataDtali", component: DataDtali,meta:{authorization:["일반 정회원","기업 정회원"]} },
+  { path: "/NoticeOne.page", name: "NoticeOne", component: NoticeOne, meta:{authorization:["비회원","준회원","일반 정회원","기업 정회원"]} },
+  { path: "/Wgcommunity.page", name: "Wgcommunity", component: Wgcommunity, meta:{authorization:["비회원","준회원","일반 정회원","기업 정회원"]} },
+  { path: "/WgcommunityOne.page", name: "WgcommunityOne", component: WgcommunityOne,meta:{authorization:["일반 정회원","기업 정회원"]}},
+  { path: "/MatchingOne.page", name: "MatchingOne", component: MatchingOne,meta:{authorization:["일반 정회원","기업 정회원"]} },
+  // { path: "/userIDsearch.page", name: "userIDsearch", component: userIDsearch,meta:{authorization:[]} },
+  { path: "/TechnologyOne.page", name: "TechnologyOne", component: TechnologyOne,meta:{authorization:["일반 정회원","기업 정회원"]}},
+  { path: "/MatchingManager.page", name: "MatchingManager", component: MatchingManager,meta:{authorization:["기업 정회원"]}},
   /* 관리자 */
   { path: "/adm.page", name: "AdminMain", component: AdminMain, meta: { requiresAuth: true },},
   { path: "/adm/login.page", name: "AdminLogin", component: AdminLogin },
client/views/pages/user/networking/Matching.vue
--- client/views/pages/user/networking/Matching.vue
+++ client/views/pages/user/networking/Matching.vue
@@ -91,6 +91,7 @@
 </template>
 
 <script>
+import { useStore } from "vuex";
 import axios from 'axios';
 import COMMON_UTIL from '../../../../resources/js/commonUtil.js';
 
@@ -112,8 +113,8 @@
             companyTop6List: [],
             companyListCount: 0,
             companyIdx: 0,
-
-            pickModalOpen: false
+            pickModalOpen: false,
+            store: useStore(),
         }
     },
     methods: {
@@ -148,14 +149,21 @@
         },
 
         pickModal: function (item) {
-
-            if (this.userCompanyId != item.company_id) {
-                if (confirm(item.company_nm + "에게 PICK 신청을 하시겠습니까?")) {
-                    this.pick(item)
+            const isUserLogin = this.store.state.loginUser;
+            if (isUserLogin.user_auth === 'common') {
+                alert("일반 회원은 해당 기능을 이용하실 수 없습니다.")
+            } else if (isUserLogin.create_account_approval === 'N' && isUserLogin.user_auth === 'company') {
+                alert("가입 승인 중 입니다. 해당 기능을 이용하실 수 없습니다.")
+            } else if (isUserLogin.create_account_approval === 'Y' && isUserLogin.user_auth === 'company') {
+                if (this.userCompanyId != item.company_id) {
+                    if (confirm(item.company_nm + "에게 PICK 신청을 하시겠습니까?")) {
+                        this.pick(item)
+                    }
+                } else {
+                    alert("자신의 기업에는 PICK을 할 수 없습니다.")
                 }
-            } else {
-                alert("자신의 기업에는 PICK을 할 수 없습니다.")
             }
+
 
         },
 
@@ -206,10 +214,10 @@
         companySelectOnePage: function (item) {
             const vm = this;
             let best = 'non'
-            for(let i =0; i < vm.companyTop6List.length; i++) {
-                if(vm.companyTop6List[i].company_id === item.company_id) {
+            for (let i = 0; i < vm.companyTop6List.length; i++) {
+                if (vm.companyTop6List[i].company_id === item.company_id) {
                     best = 'best';
-                } 
+                }
             }
             axios({
                 url: '/matching/companyViewCountAdd.json',
@@ -219,14 +227,14 @@
                 },
                 data: { 'company_id': item.company_id }
             }).then(function (response) {
-                vm.$router.push({ path: '/MatchingOne.page', query: { 'company_id': item.company_id, 'best': best} });
+                vm.$router.push({ path: '/MatchingOne.page', query: { 'company_id': item.company_id, 'best': best } });
             }).catch(function (error) {
                 console.log("기업 상세조회 오류, 관리자에게 문의하세요.");
             })
         },
 
         /**페이지 접속 로그 등록 */
-        pageLogInsert: function() {
+        pageLogInsert: function () {
             const vm = this;
 
             axios({
Add a comment
List