From a19a4ffdf74730246438b72c203d469d36c5a24c Mon Sep 17 00:00:00 2001 From: Shane Melton Date: Thu, 21 Dec 2023 15:51:48 -0800 Subject: [PATCH] [AC-1879] Add null check for collection view helpers (#7073) * [AC-1879] Add null check for collection view helpers * [AC-1879] Add additional null check to organization-options.component.ts --- .../components/organization-options.component.ts | 6 +++--- libs/common/src/vault/models/view/collection.view.ts | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/web/src/app/vault/individual-vault/vault-filter/components/organization-options.component.ts b/apps/web/src/app/vault/individual-vault/vault-filter/components/organization-options.component.ts index 675f9eb823..b7cb33d97e 100644 --- a/apps/web/src/app/vault/individual-vault/vault-filter/components/organization-options.component.ts +++ b/apps/web/src/app/vault/individual-vault/vault-filter/components/organization-options.component.ts @@ -87,9 +87,9 @@ export class OrganizationOptionsComponent implements OnInit, OnDestroy { } allowEnrollmentChanges(org: OrganizationFilter): boolean { - if (org.usePolicies && org.useResetPassword && org.hasPublicAndPrivateKeys) { + if (org?.usePolicies && org?.useResetPassword && org?.hasPublicAndPrivateKeys) { if (this.resetPasswordPolicy != undefined && this.resetPasswordPolicy.enabled) { - return !(org.resetPasswordEnrolled && this.resetPasswordPolicy.data.autoEnrollEnabled); + return !(org?.resetPasswordEnrolled && this.resetPasswordPolicy.data.autoEnrollEnabled); } } @@ -97,7 +97,7 @@ export class OrganizationOptionsComponent implements OnInit, OnDestroy { } showSsoOptions(org: OrganizationFilter) { - return org.useSso && org.identifier; + return org?.useSso && org?.identifier; } async unlinkSso(org: Organization) { diff --git a/libs/common/src/vault/models/view/collection.view.ts b/libs/common/src/vault/models/view/collection.view.ts index 79db734fae..1fdfe9e0eb 100644 --- a/libs/common/src/vault/models/view/collection.view.ts +++ b/libs/common/src/vault/models/view/collection.view.ts @@ -33,7 +33,7 @@ export class CollectionView implements View, ITreeNodeObject { // For editing collection details, not the items within it. canEdit(org: Organization, flexibleCollectionsEnabled: boolean): boolean { - if (org.id !== this.organizationId) { + if (org != null && org.id !== this.organizationId) { throw new Error( "Id of the organization provided does not match the org id of the collection.", ); @@ -46,7 +46,7 @@ export class CollectionView implements View, ITreeNodeObject { // For deleting a collection, not the items within it. canDelete(org: Organization, flexibleCollectionsEnabled: boolean): boolean { - if (org.id !== this.organizationId) { + if (org != null && org.id !== this.organizationId) { throw new Error( "Id of the organization provided does not match the org id of the collection.", );