From cf827981af3abf9d12d88bdad214b5b9f09b6243 Mon Sep 17 00:00:00 2001 From: Jason Ng Date: Thu, 20 Mar 2025 15:16:18 -0400 Subject: [PATCH] [PM-19240] Do not show task unless Manage or Edit Permission (#13880) * do not show task for edit except pw --- .../view/emergency-view-dialog.component.spec.ts | 3 +++ libs/vault/src/cipher-view/cipher-view.component.ts | 11 +++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/apps/web/src/app/auth/settings/emergency-access/view/emergency-view-dialog.component.spec.ts b/apps/web/src/app/auth/settings/emergency-access/view/emergency-view-dialog.component.spec.ts index 0021d938f82..6e96b357e3e 100644 --- a/apps/web/src/app/auth/settings/emergency-access/view/emergency-view-dialog.component.spec.ts +++ b/apps/web/src/app/auth/settings/emergency-access/view/emergency-view-dialog.component.spec.ts @@ -13,6 +13,7 @@ import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/pl import { Utils } from "@bitwarden/common/platform/misc/utils"; import { FakeAccountService, mockAccountServiceWith } from "@bitwarden/common/spec"; import { UserId } from "@bitwarden/common/types/guid"; +import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service"; import { FolderService } from "@bitwarden/common/vault/abstractions/folder/folder.service.abstraction"; import { CipherType } from "@bitwarden/common/vault/enums"; import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view"; @@ -65,6 +66,7 @@ describe("EmergencyViewDialogComponent", () => { useValue: ChangeLoginPasswordService, }, { provide: ConfigService, useValue: ConfigService }, + { provide: CipherService, useValue: mock() }, ], }, add: { @@ -79,6 +81,7 @@ describe("EmergencyViewDialogComponent", () => { useValue: mock(), }, { provide: ConfigService, useValue: mock() }, + { provide: CipherService, useValue: mock() }, ], }, }) diff --git a/libs/vault/src/cipher-view/cipher-view.component.ts b/libs/vault/src/cipher-view/cipher-view.component.ts index 1df96656da5..57c2b4dbae4 100644 --- a/libs/vault/src/cipher-view/cipher-view.component.ts +++ b/libs/vault/src/cipher-view/cipher-view.component.ts @@ -15,7 +15,8 @@ import { isCardExpired } from "@bitwarden/common/autofill/utils"; import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum"; import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service"; import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service"; -import { CollectionId, UserId } from "@bitwarden/common/types/guid"; +import { CipherId, CollectionId, UserId } from "@bitwarden/common/types/guid"; +import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service"; import { FolderService } from "@bitwarden/common/vault/abstractions/folder/folder.service.abstraction"; import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view"; import { FolderView } from "@bitwarden/common/vault/models/view/folder.view"; @@ -87,6 +88,7 @@ export class CipherViewComponent implements OnChanges, OnDestroy { private platformUtilsService: PlatformUtilsService, private changeLoginPasswordService: ChangeLoginPasswordService, private configService: ConfigService, + private cipherService: CipherService, ) {} async ngOnChanges() { @@ -152,7 +154,12 @@ export class CipherViewComponent implements OnChanges, OnDestroy { const userId = await firstValueFrom(this.activeUserId$); - if (this.cipher.edit && this.cipher.viewPassword) { + // Show Tasks for Manage and Edit permissions + // Using cipherService to see if user has access to cipher in a non-AC context to address with Edit Except Password permissions + const allCiphers = await firstValueFrom(this.cipherService.ciphers$(userId)); + const cipherServiceCipher = allCiphers[this.cipher?.id as CipherId]; + + if (cipherServiceCipher?.edit && cipherServiceCipher?.viewPassword) { await this.checkPendingChangePasswordTasks(userId); }