fix: organizationId called on possibly undefined profile array (#17123)

This commit is contained in:
Alex van Andel
2024-10-15 18:56:23 +00:00
committed by GitHub
parent 6360e73901
commit b1d509ba30
@@ -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" });
}