From 033e704cf32802930d5afc641eaf660ce579aea7 Mon Sep 17 00:00:00 2001 From: Meier Lukas Date: Sat, 9 Nov 2024 11:21:46 +0100 Subject: [PATCH] fix: integration page accessible without session --- .../src/app/[locale]/manage/integrations/page.tsx | 10 ++++++++-- apps/nextjs/src/app/[locale]/manage/layout.tsx | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/apps/nextjs/src/app/[locale]/manage/integrations/page.tsx b/apps/nextjs/src/app/[locale]/manage/integrations/page.tsx index fafc49fc8..a600effed 100644 --- a/apps/nextjs/src/app/[locale]/manage/integrations/page.tsx +++ b/apps/nextjs/src/app/[locale]/manage/integrations/page.tsx @@ -1,6 +1,7 @@ import { Fragment } from "react"; import type { PropsWithChildren } from "react"; import Link from "next/link"; +import { redirect } from "next/navigation"; import { AccordionControl, AccordionItem, @@ -50,11 +51,16 @@ interface IntegrationsPageProps { } export default async function IntegrationsPage({ searchParams }: IntegrationsPageProps) { - const integrations = await api.integration.all(); const session = await auth(); + + if (!session) { + redirect("/auth/login"); + } + + const integrations = await api.integration.all(); const t = await getScopedI18n("integration"); - const canCreateIntegrations = session?.user.permissions.includes("integration-create") ?? false; + const canCreateIntegrations = session.user.permissions.includes("integration-create"); return ( diff --git a/apps/nextjs/src/app/[locale]/manage/layout.tsx b/apps/nextjs/src/app/[locale]/manage/layout.tsx index 9403244b3..4f3657f3c 100644 --- a/apps/nextjs/src/app/[locale]/manage/layout.tsx +++ b/apps/nextjs/src/app/[locale]/manage/layout.tsx @@ -58,6 +58,7 @@ export default async function ManageLayout({ children }: PropsWithChildren) { icon: IconPlug, href: "/manage/integrations", label: t("items.integrations"), + hidden: !session, }, { icon: IconSearch,