ca groundwork

This commit is contained in:
DecDuck
2024-10-07 22:35:54 +11:00
parent 1bd19ad917
commit bfafd2a044
44 changed files with 628 additions and 130 deletions

View File

@ -0,0 +1,15 @@
const whitelistedPrefixes = ["/signin", "/register"];
export default defineNuxtRouteMiddleware(async (to, from) => {
if (import.meta.server) return;
if (whitelistedPrefixes.findIndex((e) => to.fullPath.startsWith(e)) != -1)
return;
const user = useUser();
if (user === undefined) {
await updateUser();
}
if (!user.value) {
return navigateTo({ path: "/signin", query: { redirect: to.fullPath } });
}
});