mirror of
https://github.com/bitwarden/web
synced 2026-01-02 00:23:16 +00:00
47 lines
1.8 KiB
TypeScript
47 lines
1.8 KiB
TypeScript
import { Component } from '@angular/core';
|
|
import { Router } from '@angular/router';
|
|
|
|
import { ToasterService } from 'angular2-toaster';
|
|
|
|
import { ApiService } from 'jslib-common/abstractions/api.service';
|
|
import { CryptoService } from 'jslib-common/abstractions/crypto.service';
|
|
import { I18nService } from 'jslib-common/abstractions/i18n.service';
|
|
import { LogService } from 'jslib-common/abstractions/log.service';
|
|
|
|
import { PasswordVerificationRequest } from 'jslib-common/models/request/passwordVerificationRequest';
|
|
|
|
@Component({
|
|
selector: 'app-delete-organization',
|
|
templateUrl: 'delete-organization.component.html',
|
|
})
|
|
export class DeleteOrganizationComponent {
|
|
organizationId: string;
|
|
|
|
masterPassword: string;
|
|
formPromise: Promise<any>;
|
|
|
|
constructor(private apiService: ApiService, private i18nService: I18nService,
|
|
private toasterService: ToasterService, private cryptoService: CryptoService,
|
|
private router: Router, private logService: LogService) { }
|
|
|
|
async submit() {
|
|
if (this.masterPassword == null || this.masterPassword === '') {
|
|
this.toasterService.popAsync('error', this.i18nService.t('errorOccurred'),
|
|
this.i18nService.t('masterPassRequired'));
|
|
return;
|
|
}
|
|
|
|
const request = new PasswordVerificationRequest();
|
|
request.masterPasswordHash = await this.cryptoService.hashPassword(this.masterPassword, null);
|
|
try {
|
|
this.formPromise = this.apiService.deleteOrganization(this.organizationId, request);
|
|
await this.formPromise;
|
|
this.toasterService.popAsync('success', this.i18nService.t('organizationDeleted'),
|
|
this.i18nService.t('organizationDeletedDesc'));
|
|
this.router.navigate(['/']);
|
|
} catch (e) {
|
|
this.logService.error(e);
|
|
}
|
|
}
|
|
}
|