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";
|
|
|
|
|
|
|
|
@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,
|
|
|
|
) {}
|
|
|
|
|
|
|
|
ngOnInit() {
|
|
|
|
// eslint-disable-next-line rxjs-angular/prefer-takeuntil, rxjs/no-async-subscribe
|
|
|
|
this.route.queryParams.pipe(first()).subscribe(async (qParams) => {
|
|
|
|
if (qParams.orgId != null && qParams.token != null && qParams.name != null) {
|
|
|
|
this.orgId = qParams.orgId;
|
|
|
|
this.token = qParams.token;
|
|
|
|
this.name = qParams.name;
|
|
|
|
} else {
|
|
|
|
// FIXME: Verify that this floating promise is intentional. If it is, add an explanatory comment and ensure there is proper error handling.
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
|
|
this.router.navigate(["/"]);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
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",
|
|
|
|
this.i18nService.t("accountDeleted"),
|
|
|
|
this.i18nService.t("accountDeletedDesc"),
|
|
|
|
);
|
|
|
|
// FIXME: Verify that this floating promise is intentional. If it is, add an explanatory comment and ensure there is proper error handling.
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
|
|
this.router.navigate(["/"]);
|
|
|
|
} catch (e) {
|
|
|
|
this.logService.error(e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|