mirror of
https://github.com/bitwarden/browser
synced 2025-12-16 16:23:44 +00:00
[PM-23789][PM-237090][PM-23791][PM-23792] - [Web][Desktop][Browser] - Do not import cards if policy is enabled (#15740)
* restrict item types in import * add comment * fix spec * fix dep * clean up logic
This commit is contained in:
@@ -26,6 +26,7 @@ import { CipherRequest } from "@bitwarden/common/vault/models/request/cipher.req
|
||||
import { FolderWithIdRequest } from "@bitwarden/common/vault/models/request/folder-with-id.request";
|
||||
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
|
||||
import { FolderView } from "@bitwarden/common/vault/models/view/folder.view";
|
||||
import { RestrictedItemTypesService } from "@bitwarden/common/vault/services/restricted-item-types.service";
|
||||
import { KeyService } from "@bitwarden/key-management";
|
||||
|
||||
import {
|
||||
@@ -119,6 +120,7 @@ export class ImportService implements ImportServiceAbstraction {
|
||||
private pinService: PinServiceAbstraction,
|
||||
private accountService: AccountService,
|
||||
private sdkService: SdkService,
|
||||
private restrictedItemTypesService: RestrictedItemTypesService,
|
||||
) {}
|
||||
|
||||
getImportOptions(): ImportOption[] {
|
||||
@@ -166,6 +168,17 @@ export class ImportService implements ImportServiceAbstraction {
|
||||
}
|
||||
}
|
||||
|
||||
const restrictedItemTypes = await firstValueFrom(
|
||||
this.restrictedItemTypesService.restricted$.pipe(
|
||||
map((restrictedItemTypes) => restrictedItemTypes.map((r) => r.cipherType)),
|
||||
),
|
||||
);
|
||||
|
||||
// Filter out restricted item types from the import result
|
||||
importResult.ciphers = importResult.ciphers.filter(
|
||||
(cipher) => !restrictedItemTypes.includes(cipher.type),
|
||||
);
|
||||
|
||||
if (organizationId && !selectedImportTarget && !canAccessImportExport) {
|
||||
const hasUnassignedCollections =
|
||||
importResult.collectionRelationships.length < importResult.ciphers.length;
|
||||
|
||||
Reference in New Issue
Block a user