1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-06-28 10:55:27 +02:00
bitwarden-browser/apps/web/src/app/admin-console/organizations/manage/verify-recover-delete-org.component.ts

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

59 lines
2.1 KiB
TypeScript
Raw Normal View History

2024-03-22 14:34:21 +01:00
import { Component, OnInit } from "@angular/core";
import { ActivatedRoute, Router } from "@angular/router";
import { first } from "rxjs/operators";
2024-04-09 17:56:34 +02:00
import { OrganizationApiServiceAbstraction } from "@bitwarden/common/admin-console/abstractions/organization/organization-api.service.abstraction";
2024-04-01 20:04:56 +02:00
import { OrganizationVerifyDeleteRecoverRequest } from "@bitwarden/common/admin-console/models/request/organization-verify-delete-recover.request";
2024-03-22 14:34:21 +01:00
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
import { firstValueFrom } from "rxjs";
2024-03-22 14:34:21 +01:00
@Component({
selector: "app-verify-recover-delete-org",
templateUrl: "verify-recover-delete-org.component.html",
})
export class VerifyRecoverDeleteOrgComponent implements OnInit {
name: string;
formPromise: Promise<any>;
private orgId: string;
private token: string;
constructor(
private router: Router,
2024-04-09 17:56:34 +02:00
private apiService: OrganizationApiServiceAbstraction,
2024-03-22 14:34:21 +01:00
private platformUtilsService: PlatformUtilsService,
private i18nService: I18nService,
private route: ActivatedRoute,
private logService: LogService,
) {}
async ngOnInit() {
const qParams = await firstValueFrom(this.route.queryParams);
if (qParams.orgId != null && qParams.token != null && qParams.name != null) {
this.orgId = qParams.orgId;
this.token = qParams.token;
this.name = qParams.name;
} else {
await this.router.navigate(["/"]);
}
2024-03-22 14:34:21 +01:00
}
async submit() {
try {
const request = new OrganizationVerifyDeleteRecoverRequest(this.token);
2024-04-01 20:04:56 +02:00
this.formPromise = this.apiService.recoverDeleteToken(this.orgId, request);
2024-03-22 14:34:21 +01:00
await this.formPromise;
this.platformUtilsService.showToast(
"success",
2024-04-09 18:30:54 +02:00
this.i18nService.t("organizationDeleted"),
this.i18nService.t("organizationDeletedDesc"),
2024-03-22 14:34:21 +01:00
);
await this.router.navigate(["/"]);
2024-03-22 14:34:21 +01:00
} catch (e) {
this.logService.error(e);
}
}
}