From fb501cb44d9be20f971aad55ef5b8f290ca68127 Mon Sep 17 00:00:00 2001 From: jaasen-livefront Date: Tue, 9 Jul 2024 15:29:54 -0700 Subject: [PATCH] Revert "migrate weak passwords report component" This reverts commit 0e453aafc154fee48f37bb22a7f24cdf2847a43c. --- .../pages/breach-report.component.html | 25 +++++++++---- .../reports/pages/breach-report.component.ts | 37 ++++++------------- 2 files changed, 28 insertions(+), 34 deletions(-) diff --git a/apps/web/src/app/tools/reports/pages/breach-report.component.html b/apps/web/src/app/tools/reports/pages/breach-report.component.html index 810daba081..51191ddf2d 100644 --- a/apps/web/src/app/tools/reports/pages/breach-report.component.html +++ b/apps/web/src/app/tools/reports/pages/breach-report.component.html @@ -2,17 +2,26 @@

{{ "breachDesc" | i18n }}

-
- - {{ "username" | i18n }} - - - {{ "breachCheckUsernameEmail" | i18n }} -
-
+

{{ "reportError" | i18n }}...

diff --git a/apps/web/src/app/tools/reports/pages/breach-report.component.ts b/apps/web/src/app/tools/reports/pages/breach-report.component.ts index 40c0cba830..5728d36078 100644 --- a/apps/web/src/app/tools/reports/pages/breach-report.component.ts +++ b/apps/web/src/app/tools/reports/pages/breach-report.component.ts @@ -1,5 +1,4 @@ import { Component, OnInit } from "@angular/core"; -import { FormBuilder, Validators } from "@angular/forms"; import { firstValueFrom, map } from "rxjs"; import { AuditService } from "@bitwarden/common/abstractions/audit.service"; @@ -11,46 +10,32 @@ import { BreachAccountResponse } from "@bitwarden/common/models/response/breach- templateUrl: "breach-report.component.html", }) export class BreachReportComponent implements OnInit { - loading = false; error = false; + username: string; checkedUsername: string; breachedAccounts: BreachAccountResponse[] = []; - formGroup = this.formBuilder.group({ - username: ["", { validators: [Validators.required, Validators.email], updateOn: "change" }], - }); + formPromise: Promise; constructor( private auditService: AuditService, private accountService: AccountService, - private formBuilder: FormBuilder, ) {} async ngOnInit() { - this.formGroup - .get("username") - .setValue( - await firstValueFrom(this.accountService.activeAccount$.pipe(map((a) => a?.email))), - ); + this.username = await firstValueFrom( + this.accountService.activeAccount$.pipe(map((a) => a?.email)), + ); } - submit = async () => { - this.formGroup.markAsTouched(); - - if (this.formGroup.invalid) { - return; - } - + async submit() { this.error = false; - this.loading = true; - const username = this.formGroup.value.username; + this.username = this.username.toLowerCase(); try { - this.breachedAccounts = await this.auditService.breachedAccounts(username); + this.formPromise = this.auditService.breachedAccounts(this.username); + this.breachedAccounts = await this.formPromise; } catch { this.error = true; - } finally { - this.loading = false; } - - this.checkedUsername = username; - }; + this.checkedUsername = this.username; + } }