Replace navigation redirects with abortNavigation
This commit is contained in:
@@ -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();
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user