35 lines
925 B
Plaintext
35 lines
925 B
Plaintext
export default defineNuxtRouteMiddleware((to) => {
|
|
// const auth = useAuthStore()
|
|
// const requiredPermission = to.meta.permission
|
|
// console.log('requiredPermission', auth)
|
|
// const userRole = auth.user?.role
|
|
|
|
// if (!auth.user) {
|
|
// return navigateTo('/login')
|
|
// }
|
|
|
|
// if (requiredPermission && !auth.hasPermission(requiredPermission)) {
|
|
// return navigateTo('/unauthorized')
|
|
// }
|
|
|
|
// // Kalau kamu mau batasi halaman berdasar role:
|
|
// const allowedRoles = to.meta.roles
|
|
// if (allowedRoles && !allowedRoles.includes(userRole)) {
|
|
// return navigateTo('/unauthorized')
|
|
// }
|
|
const { status, data: session } = useAuth();
|
|
if (status.value === "unauthenticated") {
|
|
console.log("status:", status.value);
|
|
} else {
|
|
console.log("status:", status.value);
|
|
}
|
|
console.log('masuk middeleware auth-menu')
|
|
|
|
|
|
console.log('route:', to.fullPath)
|
|
|
|
|
|
return navigateTo('/sample-page-copy')
|
|
})
|
|
|