Skip to content

Commit

Permalink
Removing the isUserAdmin and just using the canAccessImportExport pro…
Browse files Browse the repository at this point in the history
…perty (#6822)
  • Loading branch information
ttalty authored Nov 13, 2023
1 parent b528675 commit 9c688ba
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
9 changes: 8 additions & 1 deletion libs/importer/src/components/import.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ export class ImportComponent implements OnInit, OnDestroy {
fileContents,
this.organizationId,
this.formGroup.controls.targetSelector.value,
this.isUserAdmin(this.organizationId)
this.canAccessImportExport(this.organizationId)
);

//No errors, display success message
Expand All @@ -386,6 +386,13 @@ export class ImportComponent implements OnInit, OnDestroy {
return this.organizationService.get(this.organizationId)?.isAdmin;
}

private canAccessImportExport(organizationId?: string): boolean {
if (!organizationId) {
return false;
}
return this.organizationService.get(this.organizationId)?.canAccessImportExport;
}

getFormatInstructionTitle() {
if (this.format == null) {
return null;
Expand Down
2 changes: 1 addition & 1 deletion libs/importer/src/services/import.service.abstraction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export abstract class ImportServiceAbstraction {
fileContents: string,
organizationId?: string,
selectedImportTarget?: string,
isUserAdmin?: boolean
canAccessImportExport?: boolean
) => Promise<ImportResult>;
getImporter: (
format: ImportType | "bitwardenpasswordprotected",
Expand Down
8 changes: 6 additions & 2 deletions libs/importer/src/services/import.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export class ImportService implements ImportServiceAbstraction {
fileContents: string,
organizationId: string = null,
selectedImportTarget: string = null,
isUserAdmin: boolean
canAccessImportExport: boolean
): Promise<ImportResult> {
let importResult: ImportResult;
try {
Expand Down Expand Up @@ -147,7 +147,11 @@ export class ImportService implements ImportServiceAbstraction {
}
}

if (organizationId && Utils.isNullOrWhitespace(selectedImportTarget) && !isUserAdmin) {
if (
organizationId &&
Utils.isNullOrWhitespace(selectedImportTarget) &&
!canAccessImportExport
) {
const hasUnassignedCollections = importResult.ciphers.some(
(c) => !Array.isArray(c.collectionIds) || c.collectionIds.length == 0
);
Expand Down

0 comments on commit 9c688ba

Please sign in to comment.