admin felület különválasztva
This commit is contained in:
16
frontend_admin/middleware/auth.ts
Normal file
16
frontend_admin/middleware/auth.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
export default defineNuxtRouteMiddleware((to, from) => {
|
||||
// Skip auth check on the login page itself
|
||||
if (to.path === '/login') {
|
||||
return
|
||||
}
|
||||
|
||||
// Check for the access_token cookie
|
||||
const tokenCookie = useCookie('access_token')
|
||||
if (!tokenCookie.value) {
|
||||
return navigateTo('/login')
|
||||
}
|
||||
|
||||
// If the store is already initialized, check isAuthenticated
|
||||
// Otherwise, the token cookie presence is sufficient for the guard
|
||||
// The store's init() will validate the token on app mount
|
||||
})
|
||||
Reference in New Issue
Block a user