Skip to content

Commit 9b3f09b

Browse files
committed
🐛 [fix] 비로그인 유저 루트 디렉토리로 이동 시 모달 표시 제거
1 parent 055a1f5 commit 9b3f09b

2 files changed

Lines changed: 30 additions & 29 deletions

File tree

src/constants/common.ts

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -40,32 +40,32 @@ export const COLOR_LIST = [
4040
]
4141

4242
export const PERMITTED_URL = {
43-
UNKNOWN: ['login', 'pw-change-email'],
44-
ROLE_USER: ['my-request', 'task-request', 'edit-information', 'pw-change'],
43+
UNKNOWN: ['/login', '/pw-change-email'],
44+
ROLE_USER: ['/my-request', '/task-request', '/edit-information', '/pw-change'],
4545
ROLE_MANAGER: [
46-
'my-task',
47-
'task-board',
48-
'team-board',
49-
'statistics',
50-
'my-request',
51-
'task-request',
52-
'requested',
53-
'request-approve',
54-
'request-history',
55-
'edit-information',
56-
'pw-change'
46+
'/my-task',
47+
'/task-board',
48+
'/team-board',
49+
'/statistics',
50+
'/my-request',
51+
'/task-request',
52+
'/requested',
53+
'/request-approve',
54+
'/request-history',
55+
'/edit-information',
56+
'/pw-change'
5757
],
5858
ROLE_ADMIN: [
59-
'member-management',
60-
'user-registration',
61-
'user-update',
62-
'task-management',
63-
'category-first',
64-
'category-second',
65-
'login-logs',
66-
'api-logs',
67-
'edit-information',
68-
'pw-change'
59+
'/member-management',
60+
'/user-registration',
61+
'/user-update',
62+
'/task-management',
63+
'/category-first',
64+
'/category-second',
65+
'/login-logs',
66+
'/api-logs',
67+
'/edit-information',
68+
'/pw-change'
6969
]
7070
}
7171

src/router/index.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -137,25 +137,26 @@ router.beforeEach(async (to, from, next) => {
137137
await memberStore.updateMemberInfoWithToken()
138138
const { info } = memberStore
139139

140-
const originUrl = to.path.split('/')[1]
141-
142140
const redirectMap = {
143141
ROLE_USER: '/my-request',
144142
ROLE_MANAGER: '/my-task',
145143
ROLE_ADMIN: '/member-management'
146144
}
147145

148-
if ((info.role && to.path === '/login') || (info.role && to.path === '/')) {
146+
if ((info.role && PERMITTED_URL.UNKNOWN.includes(to.path)) || (info.role && to.path === '/')) {
149147
return next(redirectMap[info.role])
150148
}
151149

152150
if (!info.role) {
153-
if (PERMITTED_URL.UNKNOWN.includes(originUrl)) {
151+
if (PERMITTED_URL.UNKNOWN.includes(to.path)) {
154152
return next()
155153
}
156154
if (to.path === '/login') {
157155
return next()
158156
}
157+
if (to.path === '/') {
158+
return next('/login')
159+
}
159160
setError('로그인이 필요합니다')
160161
return next('/login')
161162
}
@@ -166,11 +167,11 @@ router.beforeEach(async (to, from, next) => {
166167
ROLE_ADMIN: PERMITTED_URL.ROLE_ADMIN
167168
}
168169

169-
if (from.path === redirectMap[info.role] && !permittedUrlMap[info.role].includes(originUrl)) {
170+
if (from.path === redirectMap[info.role] && !permittedUrlMap[info.role].includes(to.path)) {
170171
return false
171172
}
172173

173-
if (!permittedUrlMap[info.role].includes(originUrl)) {
174+
if (!permittedUrlMap[info.role].includes(to.path)) {
174175
if (to.path === redirectMap[info.role]) {
175176
return next()
176177
}

0 commit comments

Comments
 (0)