@@ -2,8 +2,7 @@ import { useAuthStore } from '@/store/auth'
|
|||||||
import { useRoute, useRouter } from 'vue-router'
|
import { useRoute, useRouter } from 'vue-router'
|
||||||
import { MAIN_SITE_URL, ROLE_HOME_ROUTES } from '@/enums'
|
import { MAIN_SITE_URL, ROLE_HOME_ROUTES } from '@/enums'
|
||||||
|
|
||||||
export const shouldLandOnMainSite = (auth) =>
|
const shouldLandOnMainSite = (auth) => auth.role !== 'admin' && auth.user?.status === 'approved'
|
||||||
auth.role !== 'admin' && auth.user?.status === 'approved'
|
|
||||||
|
|
||||||
export const useRedirectAfterLogin = () => {
|
export const useRedirectAfterLogin = () => {
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
|
import { ROLE_HOME_ROUTES } from '@/enums'
|
||||||
import { useAuthStore } from '@/store/auth'
|
import { useAuthStore } from '@/store/auth'
|
||||||
import { MAIN_SITE_URL, ROLE_HOME_ROUTES } from '@/enums'
|
|
||||||
import { tokenService } from '@/services/api/token-service'
|
import { tokenService } from '@/services/api/token-service'
|
||||||
import { shouldLandOnMainSite } from '@/features/auth/composables/useRedirectAfterLogin'
|
|
||||||
|
|
||||||
const APP_TITLE = 'مدرسه بانو'
|
const APP_TITLE = 'مدرسه بانو'
|
||||||
|
|
||||||
@@ -20,10 +19,6 @@ export const guestGuard = (to) => {
|
|||||||
if (!to.meta?.requiresGuest) return
|
if (!to.meta?.requiresGuest) return
|
||||||
if (tokenService.hasToken()) {
|
if (tokenService.hasToken()) {
|
||||||
const auth = useAuthStore()
|
const auth = useAuthStore()
|
||||||
if (shouldLandOnMainSite(auth)) {
|
|
||||||
window.location.href = MAIN_SITE_URL
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
return { name: ROLE_HOME_ROUTES[auth.role] || 'student-dashboard' }
|
return { name: ROLE_HOME_ROUTES[auth.role] || 'student-dashboard' }
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user