Skip to content

Commit

Permalink
chore: session constant to reduce fn calls + error message
Browse files Browse the repository at this point in the history
  • Loading branch information
peterphanouvong committed Aug 27, 2024
1 parent c676b65 commit f37a21b
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/session/getUserOrganizations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,22 @@ export const getUserOrganizationsFactory =
(req?: NextApiRequest, res?: NextApiResponse) =>
async (): Promise<KindeOrganizations | null> => {
try {
const userOrgs = await kindeClient.getUserOrganizations(
sessionManager(req, res)
);
const session = sessionManager(req, res);
const userOrgs = await kindeClient.getUserOrganizations(session);
const orgNames = (await kindeClient.getClaimValue(
sessionManager(req, res),
session,
'organizations',
'id_token'
)) as {id: string; name: string}[];

const hasuraOrgCodes = (await kindeClient.getClaimValue(
sessionManager(req, res),
session,
'x-hasura-org-codes',
'id_token'
)) as string[];

const hasuraOrganizations = (await kindeClient.getClaimValue(
sessionManager(req, res),
session,
'x-hasura-organizations',
'id_token'
)) as {id: string; name: string}[];
Expand All @@ -38,7 +37,7 @@ export const getUserOrganizationsFactory =
};
} catch (error) {
if (config.isDebugMode) {
console.debug('getUser', error);
console.debug('getUserOrganization error:', error);
}
return null;
}
Expand Down

0 comments on commit f37a21b

Please sign in to comment.