mirror of
https://github.com/bitwarden/browser
synced 2025-12-12 22:33:35 +00:00
47 lines
1.6 KiB
TypeScript
47 lines
1.6 KiB
TypeScript
import {
|
|
Component,
|
|
Input,
|
|
} from '@angular/core';
|
|
import { Router } from '@angular/router';
|
|
|
|
import { ToasterService } from 'angular2-toaster';
|
|
|
|
import { ApiService } from 'jslib-common/abstractions/api.service';
|
|
import { I18nService } from 'jslib-common/abstractions/i18n.service';
|
|
import { LogService } from 'jslib-common/abstractions/log.service';
|
|
import { UserVerificationService } from 'jslib-common/abstractions/userVerification.service';
|
|
|
|
import { Verification } from 'jslib-common/types/verification';
|
|
|
|
@Component({
|
|
selector: 'app-purge-vault',
|
|
templateUrl: 'purge-vault.component.html',
|
|
})
|
|
export class PurgeVaultComponent {
|
|
@Input() organizationId?: string = null;
|
|
|
|
masterPassword: Verification;
|
|
formPromise: Promise<any>;
|
|
|
|
constructor(private apiService: ApiService, private i18nService: I18nService,
|
|
private toasterService: ToasterService, private userVerificationService: UserVerificationService,
|
|
private router: Router, private logService: LogService) { }
|
|
|
|
async submit() {
|
|
const request = await this.userVerificationService.buildRequest(this.masterPassword);
|
|
|
|
try {
|
|
this.formPromise = this.apiService.postPurgeCiphers(request, this.organizationId);
|
|
await this.formPromise;
|
|
this.toasterService.popAsync('success', null, this.i18nService.t('vaultPurged'));
|
|
if (this.organizationId != null) {
|
|
this.router.navigate(['organizations', this.organizationId, 'vault']);
|
|
} else {
|
|
this.router.navigate(['vault']);
|
|
}
|
|
} catch (e) {
|
|
this.logService.error(e);
|
|
}
|
|
}
|
|
}
|