From 0b6d3064e2bed299f91e93388e0ee24ebfcb39c5 Mon Sep 17 00:00:00 2001 From: Leo Chen Date: Tue, 8 Oct 2024 14:13:32 +1100 Subject: [PATCH] Coalesce nulls when Hasura claims don't exist --- src/session/getUserOrganizations.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/session/getUserOrganizations.ts b/src/session/getUserOrganizations.ts index e54b89fd..120d14f9 100644 --- a/src/session/getUserOrganizations.ts +++ b/src/session/getUserOrganizations.ts @@ -20,13 +20,13 @@ export const getUserOrganizationsFactory = session, 'x-hasura-org-codes', 'id_token' - )) as string[]; + )) as string[] ?? []; const hasuraOrganizations = (await kindeClient.getClaimValue( session, 'x-hasura-organizations', 'id_token' - )) as {id: string; name: string}[]; + )) as {id: string; name: string}[] ?? []; return { orgCodes: [...userOrgs.orgCodes, ...hasuraOrgCodes],