mirror of
https://github.com/bitwarden/browser.git
synced 2024-06-28 10:55:27 +02:00
65 lines
2.5 KiB
TypeScript
65 lines
2.5 KiB
TypeScript
|
import { Component, OnInit } from "@angular/core";
|
||
|
import { ActivatedRoute, Router } from "@angular/router";
|
||
|
import { first } from "rxjs/operators";
|
||
|
|
||
|
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
||
|
import { OrganizationVerifyDeleteRecoverRequest } from "@bitwarden/common/models/request/organization-verify-delete-recover.request";
|
||
|
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",
|
||
|
})
|
||
|
// eslint-disable-next-line rxjs-angular/prefer-takeuntil
|
||
|
export class VerifyRecoverDeleteOrgComponent implements OnInit {
|
||
|
name: string;
|
||
|
formPromise: Promise<any>;
|
||
|
|
||
|
private orgId: string;
|
||
|
private token: string;
|
||
|
|
||
|
constructor(
|
||
|
private router: Router,
|
||
|
private apiService: ApiService,
|
||
|
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);
|
||
|
this.formPromise = this.apiService.postOrganizationRecoverDeleteToken(this.orgId, request);
|
||
|
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);
|
||
|
}
|
||
|
}
|
||
|
}
|