fix: bugs

This commit is contained in:
sajjadtalkhabi
2026-08-17 16:59:24 +03:30
parent b2f2f89181
commit 20551fee63
7 changed files with 39 additions and 7 deletions
@@ -1,6 +1,9 @@
import { ROLE_HOME_ROUTES } from '@/enums'
import { useAuthStore } from '@/store/auth'
import { useRoute, useRouter } from 'vue-router'
import { MAIN_SITE_URL, ROLE_HOME_ROUTES } from '@/enums'
export const shouldLandOnMainSite = (auth) =>
auth.role !== 'admin' && auth.user?.status === 'approved'
export const useRedirectAfterLogin = () => {
const router = useRouter()
@@ -13,6 +16,10 @@ export const useRedirectAfterLogin = () => {
router.push(redirect).catch(() => router.push('/'))
return
}
if (shouldLandOnMainSite(auth)) {
window.location.href = MAIN_SITE_URL
return
}
const target = { name: ROLE_HOME_ROUTES[auth.role] || 'student-dashboard' }
router.push(target).catch(() => router.push('/'))
}