1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-22 11:13:46 +00:00

[AC-1104] Fix access import/export with custom permission (#5014)

* [AC-1104] Allow importBlockedByPolicy to be overridden

Adjust the import component so that the importBlockedByPolicy flag can be overridden by the org import component to always return false.

* [AC-1104] Allow disabledByPolicy to be overridden in export component

Adjust the export component so that the disabledByPolicy flag can be overridden by the org export component to always return false.

* [AC-1104] Cleanup logic that disables export form

* [AC-1104] Use observable subscription for assigning importBlockedByPolicy flag

* [AC-1264] Add optional success callback for import component

Use the optional callback in org-import.component.ts to clear the file and file contents when the user does not have access to the vault page

* [AC-1264] Re-order properties

* [AC-1104] Refactor import component to only use onSuccess callback that can be overridden
This commit is contained in:
Shane Melton
2023-05-30 16:30:15 -07:00
committed by GitHub
parent 2f44b9b0dd
commit e092d42b72
4 changed files with 79 additions and 39 deletions

View File

@@ -54,6 +54,10 @@ export class OrganizationExportComponent extends ExportComponent {
);
}
protected get disabledByPolicy(): boolean {
return false;
}
async ngOnInit() {
// eslint-disable-next-line rxjs-angular/prefer-takeuntil, rxjs/no-async-subscribe
this.route.parent.parent.params.subscribe(async (params) => {
@@ -62,10 +66,6 @@ export class OrganizationExportComponent extends ExportComponent {
await super.ngOnInit();
}
async checkExportDisabled() {
return;
}
getExportData() {
if (this.isFileEncryptedExport) {
return this.exportService.getPasswordProtectedExport(this.filePassword, this.organizationId);

View File

@@ -1,13 +1,18 @@
import { Component } from "@angular/core";
import { ActivatedRoute, Router } from "@angular/router";
import { switchMap, takeUntil } from "rxjs/operators";
import { DialogServiceAbstraction, SimpleDialogType } from "@bitwarden/angular/services/dialog";
import { ModalService } from "@bitwarden/angular/services/modal.service";
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
import { LogService } from "@bitwarden/common/abstractions/log.service";
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
import {
canAccessVaultTab,
OrganizationService,
} from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
import { PolicyService } from "@bitwarden/common/admin-console/abstractions/policy/policy.service.abstraction";
import { Organization } from "@bitwarden/common/admin-console/models/domain/organization";
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
import { ImportServiceAbstraction } from "@bitwarden/importer";
@@ -19,7 +24,11 @@ import { ImportComponent } from "../../../../tools/import-export/import.componen
})
// eslint-disable-next-line rxjs-angular/prefer-takeuntil
export class OrganizationImportComponent extends ImportComponent {
organizationName: string;
organization: Organization;
protected get importBlockedByPolicy(): boolean {
return false;
}
constructor(
i18nService: I18nService,
@@ -47,21 +56,32 @@ export class OrganizationImportComponent extends ImportComponent {
);
}
async ngOnInit() {
// eslint-disable-next-line rxjs-angular/prefer-takeuntil, rxjs/no-async-subscribe
this.route.parent.parent.params.subscribe(async (params) => {
this.organizationId = params.organizationId;
this.successNavigate = ["organizations", this.organizationId, "vault"];
await super.ngOnInit();
});
const organization = await this.organizationService.get(this.organizationId);
this.organizationName = organization.name;
ngOnInit() {
this.route.params
.pipe(
switchMap((params) => this.organizationService.get$(params.organizationId)),
takeUntil(this.destroy$)
)
.subscribe((organization) => {
this.organizationId = organization.id;
this.organization = organization;
});
super.ngOnInit();
}
protected async onSuccessfulImport(): Promise<void> {
if (canAccessVaultTab(this.organization)) {
await this.router.navigate(["organizations", this.organizationId, "vault"]);
} else {
this.fileSelected = null;
this.fileContents = "";
}
}
async submit() {
const confirmed = await this.dialogService.openSimpleDialog({
title: { key: "warning" },
content: { key: "importWarning", placeholders: [this.organizationName] },
content: { key: "importWarning", placeholders: [this.organization.name] },
type: SimpleDialogType.WARNING,
});