Skip to content

Commit 553c6ba

Browse files
committed
🐛 [fix] 다이나믹 라우팅으로 인해 카테고리 수정 페이지 진입 불가 수정
1 parent ba3ccae commit 553c6ba

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/router/index.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,11 +170,20 @@ router.beforeEach(async (to, from, next) => {
170170
ROLE_ADMIN: PERMITTED_URL.ROLE_ADMIN
171171
}
172172

173-
if (from.path === redirectMap[info.role] && !permittedUrlMap[info.role].includes(to.path)) {
173+
const isPathPermitted = (path: string, permittedPaths: string[]) => {
174+
return permittedPaths.some(permittedPath => {
175+
return path.startsWith(permittedPath)
176+
})
177+
}
178+
179+
if (
180+
from.path === redirectMap[info.role] &&
181+
!isPathPermitted(to.path, permittedUrlMap[info.role])
182+
) {
174183
return false
175184
}
176185

177-
if (!permittedUrlMap[info.role].includes(to.path)) {
186+
if (!isPathPermitted(to.path, permittedUrlMap[info.role])) {
178187
if (to.path === redirectMap[info.role]) {
179188
return next()
180189
}

0 commit comments

Comments
 (0)