diff --git a/src/components/common/TitleContainer.vue b/src/components/common/TitleContainer.vue new file mode 100644 index 00000000..e23df834 --- /dev/null +++ b/src/components/common/TitleContainer.vue @@ -0,0 +1,12 @@ + + + diff --git a/src/components/top-bar/TopBar.vue b/src/components/top-bar/TopBar.vue index 11db57a2..e3b12a3e 100644 --- a/src/components/top-bar/TopBar.vue +++ b/src/components/top-bar/TopBar.vue @@ -55,12 +55,29 @@ import { storeToRefs } from 'pinia' import { useMemberStore } from '@/stores/member' import NotificationModal from './NotificationModal.vue' import ProfileModal from './ProfileModal.vue' +import { useRoute, useRouter } from 'vue-router' +import { PERMITTED_URL } from '@/constants/common' const memberStore = useMemberStore() const { info } = storeToRefs(memberStore) +const route = useRoute() +const router = useRouter() onMounted(async () => { await memberStore.updateMemberInfoWithToken() + + const originUrl = route.path.split('/')[1] + if (info.value.memberRole === 'ROLE_USER') { + if (!PERMITTED_URL.ROLE_USER.includes(originUrl)) router.push('/my-request') + } else if (info.value.memberRole === 'ROLE_MANAGER') { + if (!PERMITTED_URL.ROLE_MANAGER.includes(originUrl)) router.push('/my-task') + } else if (info.value.memberRole === 'ROLE_ADMIN') { + if (!PERMITTED_URL.ROLE_ADMIN.includes(originUrl)) router.push('/member-management') + } else { + if (!PERMITTED_URL.UNKNOWN.includes(originUrl)) { + router.push('/login') + } + } }) const isSideOpen = ref(false) diff --git a/src/constants/common.ts b/src/constants/common.ts index 5b8f0806..e8361b2c 100644 --- a/src/constants/common.ts +++ b/src/constants/common.ts @@ -37,3 +37,34 @@ export const COLOR_LIST = [ { borderColor: '#8B5CF6', fillColor: '#F5F3FF', colorEnum: 'PURPLE' }, { borderColor: '#A1A1AA', fillColor: '#F4F4F5', colorEnum: 'GREY' } ] + +export const PERMITTED_URL = { + UNKNOWN: ['login', 'pw-change-email', 'pw-change'], + ROLE_USER: ['my-request', 'task-request', 'edit-information', 'pw-check', 'pw-change'], + ROLE_MANAGER: [ + 'my-request', + 'task-request', + 'requested', + 'request-history', + 'my-task', + 'task-board', + 'team-board', + 'statistics', + 'task-detail', + 'edit-information', + 'pw-check', + 'pw-change' + ], + ROLE_ADMIN: [ + 'member-management', + 'edit-information', + 'task-management', + 'category-first', + 'category-second', + 'login-logs', + 'api-logs', + 'edit-information', + 'pw-check', + 'pw-change' + ] +} diff --git a/src/router/index.ts b/src/router/index.ts index a98db654..6e9cdeeb 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -8,7 +8,6 @@ const router = createRouter({ name: 'Login', component: () => import('../views/LoginView.vue') }, - { path: '/pw-change', name: 'PwChange', @@ -111,6 +110,11 @@ const router = createRouter({ path: '/statistics', name: 'Statistics', component: () => import('../views/StatisticsView.vue') + }, + { + path: '/:pathMatch(.*)*', + name: 'NotFound', + component: () => import('../views/NotFoundView.vue') } ] }) diff --git a/src/views/LoginView.vue b/src/views/LoginView.vue index 1dd39baf..808044c8 100644 --- a/src/views/LoginView.vue +++ b/src/views/LoginView.vue @@ -1,11 +1,9 @@ + + diff --git a/src/views/PwChange.vue b/src/views/PwChange.vue index 889f5454..3d726446 100644 --- a/src/views/PwChange.vue +++ b/src/views/PwChange.vue @@ -8,11 +8,9 @@
-
-

비밀번호

-

재설정

-
-

초기 비밀번호를 변경해주세요

+
이메일을 확인해주세요
-
-

비밀번호

-

재설정

-
-

가입된 아이디와 이메일을 입력해주세요

+
-
-

비밀번호

-

재설정

-
-

- 비밀번호 재설정을 위해
현재 비밀번호를 입력해주세요 -

+
import { ref } from 'vue' import router from '../router/index' +import TitleContainer from '@/components/common/TitleContainer.vue' const pw = ref('')