Add:api-login
This commit is contained in:
parent
a6cddc6318
commit
c411f2a8a4
20 changed files with 434 additions and 185 deletions
|
|
@ -1,5 +1,5 @@
|
|||
export default defineNuxtRouteMiddleware((to) => {
|
||||
const { isAuthenticated } = useAuth()
|
||||
const { isAuthenticated, user } = useAuth()
|
||||
|
||||
// Pages that are accessible only when NOT logged in (Auth pages)
|
||||
const authPages = [
|
||||
|
|
@ -17,6 +17,9 @@ export default defineNuxtRouteMiddleware((to) => {
|
|||
|
||||
// 1. If user is authenticated and tries to access login/register (Keep landing page accessible)
|
||||
if (isAuthenticated.value && authPages.includes(to.path)) {
|
||||
const role = user.value?.role?.code
|
||||
if (role === 'ADMIN') return navigateTo('/admin', { replace: true })
|
||||
if (role === 'INSTRUCTOR') return navigateTo('/instructor', { replace: true })
|
||||
return navigateTo('/dashboard', { replace: true })
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue