mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-26 12:25:20 +01:00
Revert "migrate weak passwords report component"
This reverts commit 0e453aafc1
.
This commit is contained in:
parent
0e453aafc1
commit
fb501cb44d
@ -2,17 +2,26 @@
|
|||||||
|
|
||||||
<bit-container>
|
<bit-container>
|
||||||
<p>{{ "breachDesc" | i18n }}</p>
|
<p>{{ "breachDesc" | i18n }}</p>
|
||||||
<form [bitSubmit]="submit" [formGroup]="formGroup">
|
<form #form (ngSubmit)="submit()" [appApiAction]="formPromise" ngNativeValidate>
|
||||||
<bit-form-field class="tw-w-1/2">
|
<div class="row">
|
||||||
<bit-label>{{ "username" | i18n }}</bit-label>
|
<div class="form-group col-6">
|
||||||
<input id="username" type="email" formControlName="username" bitInput />
|
<label for="username">{{ "username" | i18n }}</label>
|
||||||
</bit-form-field>
|
<input
|
||||||
<small class="form-text text-muted tw-mb-1">{{ "breachCheckUsernameEmail" | i18n }}</small>
|
id="username"
|
||||||
<button type="submit" buttonType="primary" bitButton [loading]="loading">
|
type="text"
|
||||||
|
name="Username"
|
||||||
|
class="form-control"
|
||||||
|
[(ngModel)]="username"
|
||||||
|
required
|
||||||
|
/>
|
||||||
|
<small class="form-text text-muted">{{ "breachCheckUsernameEmail" | i18n }}</small>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<button type="submit" buttonType="primary" bitButton [loading]="form.loading">
|
||||||
{{ "checkBreaches" | i18n }}
|
{{ "checkBreaches" | i18n }}
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
<div class="mt-4" *ngIf="checkedUsername">
|
<div class="mt-4" *ngIf="!form.loading && checkedUsername">
|
||||||
<p *ngIf="error">{{ "reportError" | i18n }}...</p>
|
<p *ngIf="error">{{ "reportError" | i18n }}...</p>
|
||||||
<ng-container *ngIf="!error">
|
<ng-container *ngIf="!error">
|
||||||
<app-callout type="success" title="{{ 'goodNews' | i18n }}" *ngIf="!breachedAccounts.length">
|
<app-callout type="success" title="{{ 'goodNews' | i18n }}" *ngIf="!breachedAccounts.length">
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import { Component, OnInit } from "@angular/core";
|
import { Component, OnInit } from "@angular/core";
|
||||||
import { FormBuilder, Validators } from "@angular/forms";
|
|
||||||
import { firstValueFrom, map } from "rxjs";
|
import { firstValueFrom, map } from "rxjs";
|
||||||
|
|
||||||
import { AuditService } from "@bitwarden/common/abstractions/audit.service";
|
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",
|
templateUrl: "breach-report.component.html",
|
||||||
})
|
})
|
||||||
export class BreachReportComponent implements OnInit {
|
export class BreachReportComponent implements OnInit {
|
||||||
loading = false;
|
|
||||||
error = false;
|
error = false;
|
||||||
|
username: string;
|
||||||
checkedUsername: string;
|
checkedUsername: string;
|
||||||
breachedAccounts: BreachAccountResponse[] = [];
|
breachedAccounts: BreachAccountResponse[] = [];
|
||||||
formGroup = this.formBuilder.group({
|
formPromise: Promise<BreachAccountResponse[]>;
|
||||||
username: ["", { validators: [Validators.required, Validators.email], updateOn: "change" }],
|
|
||||||
});
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private auditService: AuditService,
|
private auditService: AuditService,
|
||||||
private accountService: AccountService,
|
private accountService: AccountService,
|
||||||
private formBuilder: FormBuilder,
|
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
async ngOnInit() {
|
async ngOnInit() {
|
||||||
this.formGroup
|
this.username = await firstValueFrom(
|
||||||
.get("username")
|
this.accountService.activeAccount$.pipe(map((a) => a?.email)),
|
||||||
.setValue(
|
|
||||||
await firstValueFrom(this.accountService.activeAccount$.pipe(map((a) => a?.email))),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
submit = async () => {
|
async submit() {
|
||||||
this.formGroup.markAsTouched();
|
|
||||||
|
|
||||||
if (this.formGroup.invalid) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.error = false;
|
this.error = false;
|
||||||
this.loading = true;
|
this.username = this.username.toLowerCase();
|
||||||
const username = this.formGroup.value.username;
|
|
||||||
try {
|
try {
|
||||||
this.breachedAccounts = await this.auditService.breachedAccounts(username);
|
this.formPromise = this.auditService.breachedAccounts(this.username);
|
||||||
|
this.breachedAccounts = await this.formPromise;
|
||||||
} catch {
|
} catch {
|
||||||
this.error = true;
|
this.error = true;
|
||||||
} finally {
|
|
||||||
this.loading = false;
|
|
||||||
}
|
}
|
||||||
|
this.checkedUsername = this.username;
|
||||||
this.checkedUsername = username;
|
}
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user