From b1d509ba30ea4f79e34331a7e7723202c7763c66 Mon Sep 17 00:00:00 2001 From: Alex van Andel Date: Tue, 15 Oct 2024 19:56:23 +0100 Subject: [PATCH] fix: organizationId called on possibly undefined profile array (#17123) --- .../trpc/server/routers/viewer/organizations/list.handler.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/trpc/server/routers/viewer/organizations/list.handler.ts b/packages/trpc/server/routers/viewer/organizations/list.handler.ts index 883c627491..e737805cbe 100644 --- a/packages/trpc/server/routers/viewer/organizations/list.handler.ts +++ b/packages/trpc/server/routers/viewer/organizations/list.handler.ts @@ -11,7 +11,7 @@ type ListHandlerInput = { // This functionality is essentially the same as the teams/list.handler.ts but it's easier for SOC to have it in a separate file. export const listHandler = async ({ ctx }: ListHandlerInput) => { - const organizationId = ctx.user.organization?.id ?? ctx.user.profiles[0].organizationId; + const organizationId = ctx.user.organization?.id ?? ctx.user.profiles[0]?.organizationId; if (!organizationId) { throw new TRPCError({ code: "BAD_REQUEST", message: "You do not belong to an organization" }); }