Start admin pages

This commit is contained in:
2025-08-09 14:58:38 +02:00
parent eac877752f
commit 4189c95d38
20 changed files with 935 additions and 22 deletions
+18
View File
@@ -0,0 +1,18 @@
export default defineNuxtRouteMiddleware((to) => {
const { loggedIn, user } = useUserSession();
if (!loggedIn.value || !user.value || user.value?.role !== 'ADMIN') {
const split = to.path.endsWith('/')
? to.path.substring(0, to.path.length - 1).split('/')
: to.path.split('/');
const localePath = useLocalePath();
return navigateTo(
!user.value
? localePath(`/login?to=${to.path}`)
: localePath(
split.length > 1 ? split.slice(0, split.length - 1).join('/') : '/'
)
);
}
});