fix
Deploy banu-front / deploy (push) Successful in 1m27s

This commit is contained in:
sajjadtalkhabi
2026-07-07 17:36:43 +03:30
parent b9ef684b51
commit 38a396ba21
89 changed files with 1815 additions and 478 deletions
+17 -2
View File
@@ -1,3 +1,4 @@
import { ROLE_HOME_ROUTES } from '@/enums'
import { useAuthStore } from '@/store/auth'
import { tokenService } from '@/services/api/token-service'
@@ -18,11 +19,25 @@ export const guestGuard = (to) => {
if (!to.meta?.requiresGuest) return
if (tokenService.hasToken()) {
const auth = useAuthStore()
return auth.role === 'admin' ? { name: 'admin-dashboard' } : { name: 'student-dashboard' }
return { name: ROLE_HOME_ROUTES[auth.role] || 'student-dashboard' }
}
return
}
// Students whose account is not yet `approved` (pending/verified) must finish
// the registration wizard before reaching any authenticated page.
export const statusGuard = (to) => {
if (isPublic(to)) return
if (to.meta?.requiresGuest) return
if (to.name === 'student-register') return
if (!tokenService.hasToken()) return
const auth = useAuthStore()
if (!auth.user) return
if (auth.role && auth.role !== 'student') return
if (auth.user.status === 'approved') return
return { name: 'student-register' }
}
export const roleGuard = (to) => {
if (!to.meta?.role) return
const auth = useAuthStore()
@@ -37,4 +52,4 @@ export const titleGuard = (to) => {
document.title = title ? `${APP_TITLE} - ${title}` : APP_TITLE
}
export const guards = [authGuard, guestGuard, roleGuard]
export const guards = [authGuard, guestGuard, statusGuard, roleGuard]