From 311ae80667715fccffbfa73699c0770d483c3434 Mon Sep 17 00:00:00 2001 From: Meier Lukas Date: Thu, 20 Feb 2025 21:46:08 +0100 Subject: [PATCH] feat: redirect to login screen when no global home board (#2379) --- apps/nextjs/src/app/[locale]/boards/_layout-creator.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/apps/nextjs/src/app/[locale]/boards/_layout-creator.tsx b/apps/nextjs/src/app/[locale]/boards/_layout-creator.tsx index 446709f34..c04d6fe56 100644 --- a/apps/nextjs/src/app/[locale]/boards/_layout-creator.tsx +++ b/apps/nextjs/src/app/[locale]/boards/_layout-creator.tsx @@ -1,8 +1,9 @@ import type { JSX, PropsWithChildren } from "react"; -import { notFound } from "next/navigation"; +import { notFound, redirect } from "next/navigation"; import { AppShellMain } from "@mantine/core"; import { TRPCError } from "@trpc/server"; +import { auth } from "@homarr/auth/next"; import { BoardProvider } from "@homarr/boards/context"; import { EditModeProvider } from "@homarr/boards/edit-mode"; import { logger } from "@homarr/log"; @@ -32,8 +33,14 @@ export const createBoardLayout = ({ }: PropsWithChildren<{ params: Promise; }>) => { + const session = await auth(); const initialBoard = await getInitialBoard(await params).catch((error) => { if (error instanceof TRPCError && error.code === "NOT_FOUND") { + if (!session) { + logger.debug("No home board found for anonymous user, redirecting to login"); + redirect("/auth/login"); + } + logger.warn(error); notFound(); }