Disable Private Vault Export Policy (#482)
This commit is contained in:
parent
a85c45a34e
commit
ee1ea922a9
|
@ -1,6 +1,7 @@
|
||||||
import {
|
import {
|
||||||
Directive,
|
Directive,
|
||||||
EventEmitter,
|
EventEmitter,
|
||||||
|
OnInit,
|
||||||
Output,
|
Output,
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
|
|
||||||
|
@ -9,28 +10,43 @@ import { EventService } from 'jslib-common/abstractions/event.service';
|
||||||
import { ExportService } from 'jslib-common/abstractions/export.service';
|
import { ExportService } from 'jslib-common/abstractions/export.service';
|
||||||
import { I18nService } from 'jslib-common/abstractions/i18n.service';
|
import { I18nService } from 'jslib-common/abstractions/i18n.service';
|
||||||
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
|
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
|
||||||
|
import { PolicyService } from 'jslib-common/abstractions/policy.service';
|
||||||
|
|
||||||
import { EventType } from 'jslib-common/enums/eventType';
|
import { EventType } from 'jslib-common/enums/eventType';
|
||||||
import { HashPurpose } from 'jslib-common/enums/hashPurpose';
|
import { PolicyType } from 'jslib-common/enums/policyType';
|
||||||
|
|
||||||
@Directive()
|
@Directive()
|
||||||
export class ExportComponent {
|
export class ExportComponent implements OnInit {
|
||||||
@Output() onSaved = new EventEmitter();
|
@Output() onSaved = new EventEmitter();
|
||||||
|
|
||||||
formPromise: Promise<string>;
|
formPromise: Promise<string>;
|
||||||
masterPassword: string;
|
masterPassword: string;
|
||||||
format: 'json' | 'encrypted_json' | 'csv' = 'json';
|
format: 'json' | 'encrypted_json' | 'csv' = 'json';
|
||||||
showPassword = false;
|
showPassword = false;
|
||||||
|
disabledByPolicy: boolean = false;
|
||||||
|
|
||||||
constructor(protected cryptoService: CryptoService, protected i18nService: I18nService,
|
constructor(protected cryptoService: CryptoService, protected i18nService: I18nService,
|
||||||
protected platformUtilsService: PlatformUtilsService, protected exportService: ExportService,
|
protected platformUtilsService: PlatformUtilsService, protected exportService: ExportService,
|
||||||
protected eventService: EventService, protected win: Window) { }
|
protected eventService: EventService, private policyService: PolicyService, protected win: Window) { }
|
||||||
|
|
||||||
|
async ngOnInit() {
|
||||||
|
await this.checkExportDisabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
async checkExportDisabled() {
|
||||||
|
this.disabledByPolicy = await this.policyService.policyAppliesToUser(PolicyType.DisablePersonalVaultExport);
|
||||||
|
}
|
||||||
|
|
||||||
get encryptedFormat() {
|
get encryptedFormat() {
|
||||||
return this.format === 'encrypted_json';
|
return this.format === 'encrypted_json';
|
||||||
}
|
}
|
||||||
|
|
||||||
async submit() {
|
async submit() {
|
||||||
|
if (this.disabledByPolicy) {
|
||||||
|
this.platformUtilsService.showToast('error', null, this.i18nService.t('personalVaultExportPolicyInEffect'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (this.masterPassword == null || this.masterPassword === '') {
|
if (this.masterPassword == null || this.masterPassword === '') {
|
||||||
this.platformUtilsService.showToast('error', this.i18nService.t('errorOccurred'),
|
this.platformUtilsService.showToast('error', this.i18nService.t('errorOccurred'),
|
||||||
this.i18nService.t('invalidMasterPassword'));
|
this.i18nService.t('invalidMasterPassword'));
|
||||||
|
|
|
@ -9,4 +9,5 @@ export enum PolicyType {
|
||||||
SendOptions = 7, // Sets restrictions or defaults for Bitwarden Sends
|
SendOptions = 7, // Sets restrictions or defaults for Bitwarden Sends
|
||||||
ResetPassword = 8, // Allows orgs to use reset password : also can enable auto-enrollment during invite flow
|
ResetPassword = 8, // Allows orgs to use reset password : also can enable auto-enrollment during invite flow
|
||||||
MaximumVaultTimeout = 9, // Sets the maximum allowed vault timeout
|
MaximumVaultTimeout = 9, // Sets the maximum allowed vault timeout
|
||||||
|
DisablePersonalVaultExport = 10, // Disable personal vault export
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue