streaming, markdown, model selecting, and lots more
This commit is contained in:
@@ -1,13 +1,19 @@
|
||||
export default defineNuxtRouteMiddleware(async (to) => {
|
||||
const { loggedIn } = useAuth()
|
||||
const { session, fetchSession } = useAuth();
|
||||
|
||||
// if authenticated, and on a signin/signup page, redirect to home page
|
||||
if (to.path.toLowerCase().includes('/auth/') && loggedIn.value) {
|
||||
return navigateTo('/')
|
||||
}
|
||||
if (!session.value) {
|
||||
await fetchSession();
|
||||
}
|
||||
|
||||
// If not authenticated, and not on a signin/signup page, redirect to login page
|
||||
if (!loggedIn.value && !to.path.toLowerCase().includes('/auth/')) {
|
||||
return navigateTo('/auth/login')
|
||||
}
|
||||
})
|
||||
const loggedIn = computed(() => !!session.value);
|
||||
|
||||
// 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) ?? "/");
|
||||
}
|
||||
|
||||
// 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}`);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user