feat(#9): Nuxt 4 migration
This commit is contained in:
14
legalconsenthub/app/middleware/auth.global.ts
Normal file
14
legalconsenthub/app/middleware/auth.global.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import type { RouteLocationNormalized } from '#vue-router'
|
||||
|
||||
export default defineNuxtRouteMiddleware(async (to: RouteLocationNormalized) => {
|
||||
// https://github.com/WaldemarEnns/nuxtui-github-auth/blob/7e3110f933d5d0445d3ac89d6c84c48052b49041/middleware/auth.global.ts
|
||||
const { loggedIn } = useUserSession()
|
||||
|
||||
if (to.meta.auth === false) {
|
||||
return
|
||||
}
|
||||
|
||||
if (!loggedIn.value) {
|
||||
return navigateTo('/login')
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user