1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-21 11:35:34 +01:00

PM-8337 Add Invalid Secret Handling to Two Factor Verify Dialog (#9325)

This commit is contained in:
KiruthigaManivannan 2024-05-29 19:33:28 +05:30 committed by GitHub
parent 9d342f61cb
commit beb930902a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 26 additions and 17 deletions

View File

@ -7,8 +7,8 @@
<ng-container bitDialogContent>
<app-user-verification-form-input
formControlName="secret"
ngDefaultControl
name="secret"
[(invalidSecret)]="invalidSecret"
></app-user-verification-form-input>
</ng-container>
<ng-container bitDialogFooter>

View File

@ -10,6 +10,7 @@ import { SecretVerificationRequest } from "@bitwarden/common/auth/models/request
import { AuthResponse } from "@bitwarden/common/auth/types/auth-response";
import { TwoFactorResponse } from "@bitwarden/common/auth/types/two-factor-response";
import { Verification } from "@bitwarden/common/auth/types/verification";
import { ErrorResponse } from "@bitwarden/common/models/response/error.response";
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
import { DialogService } from "@bitwarden/components";
@ -32,6 +33,7 @@ export class TwoFactorVerifyComponent {
protected formGroup = new FormGroup({
secret: new FormControl<Verification | null>(null),
});
invalidSecret: boolean = false;
constructor(
@Inject(DIALOG_DATA) protected data: TwoFactorVerifyDialogData,
@ -45,6 +47,7 @@ export class TwoFactorVerifyComponent {
}
submit = async () => {
try {
let hashedSecret: string;
this.formPromise = this.userVerificationService
.buildRequest(this.formGroup.value.secret)
@ -62,6 +65,12 @@ export class TwoFactorVerifyComponent {
secret: hashedSecret,
verificationType: this.formGroup.value.secret.type,
});
} catch (e) {
if (e instanceof ErrorResponse && e.statusCode === 400) {
this.invalidSecret = true;
}
throw e;
}
};
get dialogTitle(): string {