
--- client/views/Login.vue
+++ client/views/Login.vue
... | ... | @@ -220,7 +220,8 @@ |
220 | 220 |
// 부모님은 Main으로 접근할 수 없음 |
221 | 221 |
else if (roles.includes("PARENT")) { |
222 | 222 |
vm.goToPage('Main_p'); |
223 |
- } else if (roles.includes("ADMIN")) { |
|
223 |
+ } |
|
224 |
+ else if (roles.includes("ADMIN")) { |
|
224 | 225 |
vm.goToPage('Dashboard'); |
225 | 226 |
} |
226 | 227 |
} |
--- client/views/pages/AppRouter.js
+++ client/views/pages/AppRouter.js
... | ... | @@ -423,62 +423,4 @@ |
423 | 423 |
routes, |
424 | 424 |
}); |
425 | 425 |
|
426 |
- |
|
427 |
-AppRouter.beforeEach((to, from, next) => { |
|
428 |
- const publicPages = ['/login.page', '/Join.page']; |
|
429 |
- const authRequired = !publicPages.includes(to.path); |
|
430 |
- |
|
431 |
- const isLoggedIn = store.getters.isLoggedIn; |
|
432 |
- |
|
433 |
- if (authRequired && !isLoggedIn) { |
|
434 |
- // 토큰이 존재하는지 확인 |
|
435 |
- const token = localStorage.getItem('token'); |
|
436 |
- if (token) { |
|
437 |
- // 토큰 유효성 검증 |
|
438 |
- axios.post('/auth/validateToken.json', {}, { |
|
439 |
- headers: { |
|
440 |
- Authorization: token |
|
441 |
- } |
|
442 |
- }).then(response => { |
|
443 |
- if (response.data.status === 'success') { |
|
444 |
- const userInfo = response.data.userInfo; |
|
445 |
- store.commit('setToken', token); |
|
446 |
- store.commit('setUser', userInfo.usid); |
|
447 |
- store.commit('setAuthcd', userInfo.author[0].authorCode); |
|
448 |
- const roles = userInfo.author.map(role => role.authorCode); |
|
449 |
- |
|
450 |
- // 학생은 Main_t로 접근할 수 없음 |
|
451 |
- if (roles.includes("STUDENT")) { |
|
452 |
- next('Dashboard.page'); |
|
453 |
- } |
|
454 |
- // 선생님은 Main으로 접근할 수 없음 |
|
455 |
- else if (roles.includes("TEACHER")) { |
|
456 |
- next('Board.page'); |
|
457 |
- } else if (roles.includes("PARENT")) { |
|
458 |
- next('Main_p.page'); |
|
459 |
- } else if (roles.includes("ADMIN")){ |
|
460 |
- next('Dashboard.page'); |
|
461 |
- } |
|
462 |
- } else { |
|
463 |
- // 유효하지 않은 경우 |
|
464 |
- alert("계정이 로그아웃되었습니다"); |
|
465 |
- localStorage.removeItem('token'); |
|
466 |
- next("login.page"); |
|
467 |
- } |
|
468 |
- }).catch(error => { |
|
469 |
- alert("계정이 로그아웃되었습니다"); |
|
470 |
- |
|
471 |
- console.error('토큰 검증 오류:', error); |
|
472 |
- localStorage.removeItem('token'); |
|
473 |
- next("login.page"); |
|
474 |
- }); |
|
475 |
- } else { |
|
476 |
- next("login.page"); |
|
477 |
- } |
|
478 |
- } else { |
|
479 |
- next(); |
|
480 |
- } |
|
481 |
-}); |
|
482 |
- |
|
483 |
- |
|
484 | 426 |
export default AppRouter; |
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?