18 lines
367 B
TypeScript
18 lines
367 B
TypeScript
export default defineNuxtRouteMiddleware((to) => {
|
|
// Skip auth for public pages
|
|
if (to.meta.auth === false) {
|
|
return;
|
|
}
|
|
|
|
// Check if user is authenticated
|
|
const authState = useState('auth.state', () => ({
|
|
authenticated: false,
|
|
user: null,
|
|
groups: [],
|
|
}));
|
|
|
|
if (!authState.value.authenticated) {
|
|
return navigateTo('/login');
|
|
}
|
|
});
|