export default defineNuxtRouteMiddleware(async (to, from) => { const auth = useAuthStore() // Wenn nicht eingeloggt → auf /login (außer er will schon dahin) if (!auth.user && !["/login", "/password-reset"].includes(to.path)) { return navigateTo("/login") } // Wenn eingeloggt → von /login auf /dashboard umleiten if (auth.user && !auth.user?.must_change_password && to.path === "/login") { return navigateTo("/") } else if(auth.user && auth.user.must_change_password && to.path !== "/password-change") { return navigateTo("/password-change") } })