From 92e357f141ff2aa4730e4a6ec316b7524fec863a Mon Sep 17 00:00:00 2001 From: Mohamed Bassem Date: Sun, 14 Sep 2025 11:57:11 +0000 Subject: fix(web): Handle user deletion more gracefully --- apps/web/app/dashboard/layout.tsx | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'apps') diff --git a/apps/web/app/dashboard/layout.tsx b/apps/web/app/dashboard/layout.tsx index 1471bfde..911d542c 100644 --- a/apps/web/app/dashboard/layout.tsx +++ b/apps/web/app/dashboard/layout.tsx @@ -7,6 +7,7 @@ import { Separator } from "@/components/ui/separator"; import { UserSettingsContextProvider } from "@/lib/userSettings"; import { api } from "@/server/api/client"; import { getServerAuthSession } from "@/server/auth"; +import { TRPCError } from "@trpc/server"; import { TFunction } from "i18next"; import { Archive, @@ -18,6 +19,7 @@ import { } from "lucide-react"; import { PluginManager, PluginType } from "@karakeep/shared/plugins"; +import { tryCatch } from "@karakeep/shared/tryCatch"; export default async function Dashboard({ children, @@ -32,10 +34,26 @@ export default async function Dashboard({ } const [lists, userSettings] = await Promise.all([ - api.lists.list(), - api.users.settings(), + tryCatch(api.lists.list()), + tryCatch(api.users.settings()), ]); + if (userSettings.error) { + if (userSettings.error instanceof TRPCError) { + if ( + userSettings.error.code === "NOT_FOUND" || + userSettings.error.code === "UNAUTHORIZED" + ) { + redirect("/logout"); + } + } + throw userSettings.error; + } + + if (lists.error) { + throw lists.error; + } + const items = (t: TFunction) => [ { @@ -79,7 +97,7 @@ export default async function Dashboard({ ]; return ( - + - + } /> -- cgit v1.2.3-70-g09d2