mirror of
https://github.com/bitwarden/browser
synced 2025-12-14 15:23:33 +00:00
[PM-19240] Do not show task unless Manage or Edit Permission (#13880)
* do not show task for edit except pw
This commit is contained in:
@@ -13,6 +13,7 @@ import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/pl
|
|||||||
import { Utils } from "@bitwarden/common/platform/misc/utils";
|
import { Utils } from "@bitwarden/common/platform/misc/utils";
|
||||||
import { FakeAccountService, mockAccountServiceWith } from "@bitwarden/common/spec";
|
import { FakeAccountService, mockAccountServiceWith } from "@bitwarden/common/spec";
|
||||||
import { UserId } from "@bitwarden/common/types/guid";
|
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 { FolderService } from "@bitwarden/common/vault/abstractions/folder/folder.service.abstraction";
|
||||||
import { CipherType } from "@bitwarden/common/vault/enums";
|
import { CipherType } from "@bitwarden/common/vault/enums";
|
||||||
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
|
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
|
||||||
@@ -65,6 +66,7 @@ describe("EmergencyViewDialogComponent", () => {
|
|||||||
useValue: ChangeLoginPasswordService,
|
useValue: ChangeLoginPasswordService,
|
||||||
},
|
},
|
||||||
{ provide: ConfigService, useValue: ConfigService },
|
{ provide: ConfigService, useValue: ConfigService },
|
||||||
|
{ provide: CipherService, useValue: mock<CipherService>() },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
add: {
|
add: {
|
||||||
@@ -79,6 +81,7 @@ describe("EmergencyViewDialogComponent", () => {
|
|||||||
useValue: mock<ChangeLoginPasswordService>(),
|
useValue: mock<ChangeLoginPasswordService>(),
|
||||||
},
|
},
|
||||||
{ provide: ConfigService, useValue: mock<ConfigService>() },
|
{ provide: ConfigService, useValue: mock<ConfigService>() },
|
||||||
|
{ provide: CipherService, useValue: mock<CipherService>() },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -15,7 +15,8 @@ import { isCardExpired } from "@bitwarden/common/autofill/utils";
|
|||||||
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";
|
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";
|
||||||
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
|
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
|
||||||
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.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 { FolderService } from "@bitwarden/common/vault/abstractions/folder/folder.service.abstraction";
|
||||||
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
|
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
|
||||||
import { FolderView } from "@bitwarden/common/vault/models/view/folder.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 platformUtilsService: PlatformUtilsService,
|
||||||
private changeLoginPasswordService: ChangeLoginPasswordService,
|
private changeLoginPasswordService: ChangeLoginPasswordService,
|
||||||
private configService: ConfigService,
|
private configService: ConfigService,
|
||||||
|
private cipherService: CipherService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
async ngOnChanges() {
|
async ngOnChanges() {
|
||||||
@@ -152,7 +154,12 @@ export class CipherViewComponent implements OnChanges, OnDestroy {
|
|||||||
|
|
||||||
const userId = await firstValueFrom(this.activeUserId$);
|
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);
|
await this.checkPendingChangePasswordTasks(userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user