bitwarden-estensione-browser/src/app/tools/breach-report.component.ts

39 lines
1.1 KiB
TypeScript

import {
Component,
OnInit,
} from '@angular/core';
import { AuditService } from 'jslib/abstractions/audit.service';
import { UserService } from 'jslib/abstractions/user.service';
import { BreachAccountResponse } from 'jslib/models/response/breachAccountResponse';
@Component({
selector: 'app-breach-report',
templateUrl: 'breach-report.component.html',
})
export class BreachReportComponent implements OnInit {
error = false;
username: string;
checkedUsername: string;
breachedAccounts: BreachAccountResponse[] = [];
formPromise: Promise<BreachAccountResponse[]>;
constructor(private auditService: AuditService, private userService: UserService) { }
async ngOnInit() {
this.username = await this.userService.getEmail();
}
async submit() {
this.error = false;
this.username = this.username.toLowerCase();
try {
this.formPromise = this.auditService.breachedAccounts(this.username);
this.breachedAccounts = await this.formPromise;
} catch {
this.error = true;
}
this.checkedUsername = this.username;
}
}