@@ -257,9 +256,7 @@ export function OrganizationSwitcher({
/>
-
- {"No results found"}
-
+ {"No results found"}
{organizations.map((org) => (
- {status === "executing" &&
- pendingOrgId === org.id ? (
+ {status === "executing" && pendingOrgId === org.id ? (
) : currentOrganization?.id === org.id ? (
@@ -287,9 +283,7 @@ export function OrganizationSwitcher({
isCollapsed={false}
className="mr-2 h-6 w-6"
/>
-
- {getDisplayName(org)}
-
+ {getDisplayName(org)}
))}
diff --git a/apps/app/src/middleware.ts b/apps/app/src/middleware.ts
index 8b964f5435..b4ff6868c3 100644
--- a/apps/app/src/middleware.ts
+++ b/apps/app/src/middleware.ts
@@ -4,53 +4,50 @@ import { headers } from "next/headers";
import { NextRequest, NextResponse } from "next/server";
export const config = {
- runtime: "nodejs",
- matcher: [
- // Skip auth-related routes
- "/((?!api|_next/static|_next/image|favicon.ico|monitoring|ingest|onboarding|research).*)",
- ],
+ runtime: "nodejs",
+ matcher: [
+ // Skip auth-related routes
+ "/((?!api|_next/static|_next/image|favicon.ico|monitoring|ingest|onboarding|research).*)",
+ ],
};
export async function middleware(request: NextRequest) {
- const session = await auth.api.getSession({
- headers: await headers(),
- });
-
- const response = NextResponse.next();
- const nextUrl = request.nextUrl;
-
- // Add x-path-name
- response.headers.set("x-pathname", nextUrl.pathname);
-
- // 1. Not authenticated
- if (!session && nextUrl.pathname !== "/auth") {
- const url = new URL("/auth", request.url);
-
- return NextResponse.redirect(url);
- }
-
- // 2. Authenticated; redirect to onboarding if not completed
- if (session) {
- // 2.1. If the user has an active organization, redirect to implementation
- if (
- session.session.activeOrganizationId &&
- nextUrl.pathname !== "/auth" &&
- !nextUrl.pathname.startsWith("/setup/onboarding")
- ) {
- const onboarding = await db.onboarding.findFirst({
- where: {
- organizationId: session.session
- .activeOrganizationId as string,
- },
- });
-
- if (!onboarding?.completed && !onboarding?.triggerJobId) {
- return NextResponse.redirect(
- new URL("/setup/onboarding", request.url),
- );
- }
- }
- }
-
- return response;
+ const session = await auth.api.getSession({
+ headers: await headers(),
+ });
+
+ const response = NextResponse.next();
+ const nextUrl = request.nextUrl;
+
+ // Add x-path-name
+ response.headers.set("x-pathname", nextUrl.pathname);
+
+ // 1. Not authenticated
+ if (!session && nextUrl.pathname !== "/auth") {
+ const url = new URL("/auth", request.url);
+
+ return NextResponse.redirect(url);
+ }
+
+ // 2. Authenticated; redirect to onboarding if not completed
+ if (session) {
+ // 2.1. If the user has an active organization, redirect to implementation
+ if (
+ session.session.activeOrganizationId &&
+ nextUrl.pathname !== "/auth" &&
+ !nextUrl.pathname.startsWith("/setup/onboarding")
+ ) {
+ const onboarding = await db.onboarding.findFirst({
+ where: {
+ organizationId: session.session.activeOrganizationId as string,
+ },
+ });
+
+ if (onboarding && !onboarding.completed && !onboarding.triggerJobId) {
+ return NextResponse.redirect(new URL("/setup/onboarding", request.url));
+ }
+ }
+ }
+
+ return response;
}