2018-06-28 17:58:33 +02:00
|
|
|
import { Component, OnInit } from "@angular/core";
|
|
|
|
|
2022-06-14 17:10:53 +02:00
|
|
|
import { AuditService } from "@bitwarden/common/abstractions/audit.service";
|
|
|
|
import { StateService } from "@bitwarden/common/abstractions/state.service";
|
|
|
|
import { BreachAccountResponse } from "@bitwarden/common/models/response/breachAccountResponse";
|
2018-06-28 17:58:33 +02:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: "app-breach-report",
|
|
|
|
templateUrl: "breach-report.component.html",
|
|
|
|
})
|
|
|
|
export class BreachReportComponent implements OnInit {
|
|
|
|
error = false;
|
2018-06-29 14:21:08 +02:00
|
|
|
username: string;
|
|
|
|
checkedUsername: string;
|
2018-06-28 17:58:33 +02:00
|
|
|
breachedAccounts: BreachAccountResponse[] = [];
|
2018-06-29 14:21:08 +02:00
|
|
|
formPromise: Promise<BreachAccountResponse[]>;
|
2018-06-28 17:58:33 +02:00
|
|
|
|
2021-12-14 17:10:26 +01:00
|
|
|
constructor(private auditService: AuditService, private stateService: StateService) {}
|
2018-06-28 17:58:33 +02:00
|
|
|
|
|
|
|
async ngOnInit() {
|
2021-12-14 17:10:26 +01:00
|
|
|
this.username = await this.stateService.getEmail();
|
2018-06-29 14:21:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
async submit() {
|
|
|
|
this.error = false;
|
|
|
|
this.username = this.username.toLowerCase();
|
2018-06-28 17:58:33 +02:00
|
|
|
try {
|
2018-06-29 14:21:08 +02:00
|
|
|
this.formPromise = this.auditService.breachedAccounts(this.username);
|
|
|
|
this.breachedAccounts = await this.formPromise;
|
2018-06-28 17:58:33 +02:00
|
|
|
} catch {
|
|
|
|
this.error = true;
|
|
|
|
}
|
2018-06-29 14:21:08 +02:00
|
|
|
this.checkedUsername = this.username;
|
2021-12-17 15:57:11 +01:00
|
|
|
}
|
2018-06-28 17:58:33 +02:00
|
|
|
}
|