feat: мультироль
🚀 Create and publish a Docker image / Detect changes in backend and frontend (push) Successful in 9s
🚀 Create and publish a Docker image / Build & publish backend image (push) Successful in 2m6s
🚀 Create and publish a Docker image / Build & publish frontend image (push) Successful in 26s
🚀 Create and publish a Docker image / Update stack on Portainer (push) Successful in 6s

This commit is contained in:
2026-05-11 21:29:16 +03:00
parent 3b0bbfc858
commit 6824d7ce7d
29 changed files with 1350 additions and 95 deletions
+7 -4
View File
@@ -39,16 +39,19 @@ const router = createRouter({
router.beforeEach(async (to) => {
const auth = useAuthStore()
const resolveDefaultRoute = () => {
if (auth.user?.activeRole === 'teacher') return '/teacher'
if (auth.user?.activeRole === 'admin') return '/admin'
return '/'
}
if (!auth.initialized && !to.meta.public) {
await auth.initialize()
}
if (!to.meta.public && !auth.isAuthenticated) {
return '/login'
}
if (to.meta.role && auth.user && auth.user.role !== to.meta.role) {
if (auth.user.role === 'teacher') return '/teacher'
if (auth.user.role === 'admin') return '/admin'
return '/'
if (to.meta.role && auth.user && !auth.user.roles.includes(to.meta.role as 'student' | 'teacher' | 'admin')) {
return resolveDefaultRoute()
}
})