use new tools-password-strength component (#10125)

This commit is contained in:
rr-bw 2024-07-16 09:14:39 -07:00 committed by GitHub
parent 69a37a884f
commit e2c99c2cdf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 9 deletions

View File

@ -27,12 +27,12 @@
</bit-hint>
</bit-form-field>
<app-password-strength
[password]="formGroup.controls.password.value"
[email]="email"
<tools-password-strength
[showText]="true"
(passwordStrengthResult)="getPasswordStrengthResult($event)"
></app-password-strength>
[email]="email"
[password]="formGroup.controls.password.value"
(passwordStrengthScore)="getPasswordStrengthScore($event)"
></tools-password-strength>
</div>
<bit-form-field>

View File

@ -2,6 +2,10 @@ import { Component, EventEmitter, Input, OnInit, Output } from "@angular/core";
import { ReactiveFormsModule, FormBuilder, Validators } from "@angular/forms";
import { JslibModule } from "@bitwarden/angular/jslib.module";
import {
PasswordStrengthScore,
PasswordStrengthV2Component,
} from "@bitwarden/angular/tools/password-strength/password-strength-v2.component";
import { AuditService } from "@bitwarden/common/abstractions/audit.service";
import { PolicyService } from "@bitwarden/common/admin-console/abstractions/policy/policy.service.abstraction";
import { MasterPasswordPolicyOptions } from "@bitwarden/common/admin-console/models/domain/master-password-policy-options";
@ -40,6 +44,7 @@ import { PasswordInputResult } from "./password-input-result";
ReactiveFormsModule,
SharedModule,
PasswordCalloutComponent,
PasswordStrengthV2Component,
JslibModule,
],
})
@ -56,7 +61,7 @@ export class InputPasswordComponent implements OnInit {
protected minPasswordLength = Utils.minimumPasswordLength;
protected minPasswordMsg = "";
protected passwordStrengthResult: any;
protected passwordStrengthScore: PasswordStrengthScore;
protected showErrorSummary = false;
protected showPassword = false;
@ -112,8 +117,8 @@ export class InputPasswordComponent implements OnInit {
}
}
getPasswordStrengthResult(result: any) {
this.passwordStrengthResult = result;
getPasswordStrengthScore(score: PasswordStrengthScore) {
this.passwordStrengthScore = score;
}
protected submit = async () => {
@ -147,7 +152,7 @@ export class InputPasswordComponent implements OnInit {
if (
this.masterPasswordPolicyOptions != null &&
!this.policyService.evaluateMasterPassword(
this.passwordStrengthResult.score,
this.passwordStrengthScore,
password,
this.masterPasswordPolicyOptions,
)