Replace navigation redirects with abortNavigation

This commit is contained in:
2025-08-11 17:48:06 +02:00
parent b607380a68
commit f1205a92df

View File

@@ -6,10 +6,10 @@ export default defineNuxtRouteMiddleware(async (to, next) => {
const auth = status.value === "authenticated" ? true : false;
const isProtected = (await to.meta.auth) === true ? true : false;
if (!auth && isProtected) {
console.log("User is not authenticated and page is protected");
return navigateTo("/login");
// User is not authenticated and page is protected
return abortNavigation();
} else if (auth && !isProtected) {
console.log("User is authenticated and page is not protected");
return navigateTo("/");
// User is authenticated and page is not protected
return abortNavigation();
}
});