diff --git a/server/routers/org/listOrgs.ts b/server/routers/org/listOrgs.ts index e0cc231c..1bb1393b 100644 --- a/server/routers/org/listOrgs.ts +++ b/server/routers/org/listOrgs.ts @@ -46,8 +46,6 @@ export async function listOrgs( const { limit, offset } = parsedQuery.data; - logger.debug("here0") - // Use the userOrgs passed from the middleware const userOrgIds = req.userOrgIds; @@ -66,7 +64,6 @@ export async function listOrgs( message: "No organizations found for the user", status: HttpCode.OK, }); - logger.debug("here1") } const organizations = await db diff --git a/src/app/layout.tsx b/src/app/layout.tsx index 66f969e6..3107fad3 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -24,24 +24,22 @@ export default async function RootLayout({ }>) { const user = await verifySession(); - console.log("layout.tsx user", user); - let orgs: ListOrgsResponse["orgs"] = []; - // if (user) { - // try { - // const res = await internal.get>( - // `/orgs`, - // await authCookieHeader() - // ); - // if (res && res.data.data.orgs) { - // orgs = res.data.data.orgs; - // } - // } catch {} + if (user) { + try { + const res = await internal.get>( + `/orgs`, + await authCookieHeader() + ); + if (res && res.data.data.orgs) { + orgs = res.data.data.orgs; + } + } catch {} - // if (!orgs.length) { - // redirect(`/setup`); - // } - // } + if (!orgs.length) { + redirect(`/setup`); + } + } return ( diff --git a/src/app/page.tsx b/src/app/page.tsx index faa0e1a4..cb3ea007 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -4,34 +4,33 @@ import { verifySession } from "@app/lib/auth/verifySession"; import { LandingProvider } from "@app/providers/LandingProvider"; import { ListOrgsResponse } from "@server/routers/org"; import { AxiosResponse } from "axios"; -import { ArrowUpLeft, ArrowUpRight } from "lucide-react"; +import { ArrowUpRight } from "lucide-react"; import Link from "next/link"; import { redirect } from "next/navigation"; export default async function Page(props: { searchParams: Promise<{ [key: string]: string | string[] | undefined }>; }) { - - const params = await props.searchParams; + const params = await props.searchParams; // this is needed to prevent static optimization const user = await verifySession(); - console.log("page.tsx user", user); - if (!user) { - // redirect("/auth/login"); + redirect("/auth/login"); return; } - // let orgs: ListOrgsResponse["orgs"] = []; - // try { - // const res = await internal.get>( - // `/orgs`, - // await authCookieHeader() - // ); - // if (res && res.data.data.orgs) { - // orgs = res.data.data.orgs; - // } - // } catch (e) {} + let orgs: ListOrgsResponse["orgs"] = []; + try { + const res = await internal.get>( + `/orgs`, + await authCookieHeader() + ); + if (res && res.data.data.orgs) { + orgs = res.data.data.orgs; + } + } catch (e) { + console.error(e); + } return ( <> @@ -39,7 +38,7 @@ export default async function Page(props: {

Logged in as {user.email}

- {/*
+
{orgs.map((org) => ( ))} -
*/} +
); }