From 53cb9c4734496bced5c72a242f5013d735aa9d9f Mon Sep 17 00:00:00 2001 From: Abhinav Gupta Date: Mon, 15 Mar 2021 13:29:29 +0530 Subject: [PATCH 1/2] Handled the case where an user has no roles for an organization --- packages/export-to-csv/src/util/index.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/export-to-csv/src/util/index.js b/packages/export-to-csv/src/util/index.js index a982ea39eb..dd6eca3273 100644 --- a/packages/export-to-csv/src/util/index.js +++ b/packages/export-to-csv/src/util/index.js @@ -52,8 +52,11 @@ function getOrganizationsWhereUserIsAdmin(managementAPIClient) { .getUser({include_orgs_roles: true}) .then(response => { let organizations = response.organizations.filter(org => { - const org_role = org.org_roles.shift() - return org_role.admin + if (org.org_roles) { + const org_role = org.org_roles.shift() + return org_role.admin + } + return false }) organizations.forEach(org => { result[org.name] = org.uid From bbf5278e213fdca754ae8c8cf86b97f225b0b979 Mon Sep 17 00:00:00 2001 From: Abhinav Gupta Date: Mon, 15 Mar 2021 13:29:29 +0530 Subject: [PATCH 2/2] Handled the case where a user has no roles for an organization --- packages/export-to-csv/src/util/index.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/export-to-csv/src/util/index.js b/packages/export-to-csv/src/util/index.js index a982ea39eb..dd6eca3273 100644 --- a/packages/export-to-csv/src/util/index.js +++ b/packages/export-to-csv/src/util/index.js @@ -52,8 +52,11 @@ function getOrganizationsWhereUserIsAdmin(managementAPIClient) { .getUser({include_orgs_roles: true}) .then(response => { let organizations = response.organizations.filter(org => { - const org_role = org.org_roles.shift() - return org_role.admin + if (org.org_roles) { + const org_role = org.org_roles.shift() + return org_role.admin + } + return false }) organizations.forEach(org => { result[org.name] = org.uid