1
0
mirror of https://github.com/bitwarden/browser.git synced 2025-03-13 13:49:37 +01:00

fix(NewDeviceVerification): [Auth/PM-18641] Show translated invalid code error on enter keypress (#13740)

This commit is contained in:
Jared Snider 2025-03-07 12:56:21 -05:00 committed by GitHub
parent d4c74287fc
commit 264ceaa82a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -15,7 +15,6 @@ import {
FormFieldModule,
IconButtonModule,
LinkModule,
ToastService,
} from "@bitwarden/components";
import { LoginEmailServiceAbstraction } from "../../common/abstractions/login-email.service";
@ -60,7 +59,6 @@ export class NewDeviceVerificationComponent implements OnInit, OnDestroy {
private apiService: ApiService,
private loginStrategyService: LoginStrategyServiceAbstraction,
private logService: LogService,
private toastService: ToastService,
private i18nService: I18nService,
private syncService: SyncService,
private loginEmailService: LoginEmailServiceAbstraction,
@ -153,9 +151,17 @@ export class NewDeviceVerificationComponent implements OnInit, OnDestroy {
await this.router.navigate(["/vault"]);
} catch (e) {
this.logService.error(e);
const errorMessage =
(e as any)?.response?.error_description ?? this.i18nService.t("errorOccurred");
let errorMessage =
((e as any)?.response?.error_description as string) ?? this.i18nService.t("errorOccurred");
if (errorMessage.includes("Invalid New Device OTP")) {
errorMessage = this.i18nService.t("invalidVerificationCode");
}
codeControl.setErrors({ serverError: { message: errorMessage } });
// For enter key press scenarios, we have to manually mark the control as touched
// to get the error message to display
codeControl.markAsTouched();
}
};
}