2018-06-28 17:58:33 +02:00
|
|
|
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;
|
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
|
|
|
|
|
|
|
constructor(private auditService: AuditService, private userService: UserService) { }
|
|
|
|
|
|
|
|
async ngOnInit() {
|
2018-06-29 14:21:08 +02:00
|
|
|
this.username = await this.userService.getEmail();
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
2018-06-28 17:58:33 +02:00
|
|
|
}
|
|
|
|
}
|