feat: add better provider support, icons, regen, and a lot more

This commit is contained in:
Zoe
2026-02-12 14:56:13 +00:00
parent d5a5945c03
commit d29f95bacf
124 changed files with 6374 additions and 1861 deletions
+23 -13
View File
@@ -1,19 +1,29 @@
export default defineNuxtRouteMiddleware(async (to) => {
const { session, fetchSession } = useAuth();
const { session: rawSession, fetchSession } = useAuth();
let session = rawSession.value;
if (!session.value) {
await fetchSession();
}
const isAuthPage = to.path.toLowerCase().includes("/auth/");
const loggedIn = computed(() => !!session.value);
// Only fetch session if not on auth pages (prevents race condition after logout)
if (!rawSession.value && !isAuthPage) {
const result = await fetchSession();
if (result.ok) {
session = result.data.session;
} else {
console.error("Failed to fetch session:", result.error);
session = null;
}
}
// if authenticated, and on a signin/signup page, redirect to home page
if (to.path.toLowerCase().includes("/auth/") && loggedIn.value) {
return await navigateTo((to.query.to as string) ?? "/");
}
const loggedIn = computed(() => !!session);
// If not authenticated, and not on a signin/signup page, redirect to login page
if (!loggedIn.value && !to.path.toLowerCase().includes("/auth/")) {
return await navigateTo(`/auth/login?to=${to.path}`);
}
// if authenticated, and on a signin/signup page, redirect to home page
if (isAuthPage && loggedIn.value) {
return await navigateTo((to.query.to as string) ?? "/");
}
// If not authenticated, and not on a signin/signup page, redirect to login page
if (!loggedIn.value && !isAuthPage) {
return await navigateTo(`/auth/login?to=${to.path}`);
}
});