fix: organizationId called on possibly undefined profile array (#17123)
This commit is contained in:
@@ -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" });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user