diff --git a/apps/web/src/app/auth/settings/emergency-access/takeover/emergency-access-takeover-dialog.component.ts b/apps/web/src/app/auth/settings/emergency-access/takeover/emergency-access-takeover-dialog.component.ts index 844e4521c8f..b5a1d85f359 100644 --- a/apps/web/src/app/auth/settings/emergency-access/takeover/emergency-access-takeover-dialog.component.ts +++ b/apps/web/src/app/auth/settings/emergency-access/takeover/emergency-access-takeover-dialog.component.ts @@ -62,7 +62,7 @@ type EmergencyAccessTakeoverDialogResultType = }) export class EmergencyAccessTakeoverDialogComponent implements OnInit, AfterViewInit { @ViewChild(InputPasswordComponent) - inputPasswordComponent!: InputPasswordComponent; + inputPasswordComponent: InputPasswordComponent | undefined = undefined; private submittingBehaviorSubject = new BehaviorSubject(false); submitting$ = this.submittingBehaviorSubject.asObservable(); @@ -108,6 +108,10 @@ export class EmergencyAccessTakeoverDialogComponent implements OnInit, AfterView } protected handlePrimaryButtonClick = async () => { + if (!this.inputPasswordComponent) { + throw new Error("InputPasswordComponent is not initialized"); + } + await this.inputPasswordComponent.submit(); }; diff --git a/libs/auth/src/angular/input-password/input-password.component.ts b/libs/auth/src/angular/input-password/input-password.component.ts index 1f037a088de..c935d0319bf 100644 --- a/libs/auth/src/angular/input-password/input-password.component.ts +++ b/libs/auth/src/angular/input-password/input-password.component.ts @@ -119,7 +119,9 @@ export class InputPasswordComponent implements OnInit { private submittingBehaviorSubject = new BehaviorSubject(false); submitting$ = this.submittingBehaviorSubject.asObservable(); - @ViewChild(PasswordStrengthV2Component) passwordStrengthComponent!: PasswordStrengthV2Component; + @ViewChild(PasswordStrengthV2Component) passwordStrengthComponent: + | PasswordStrengthV2Component + | undefined = undefined; @Output() onPasswordFormSubmit = new EventEmitter(); @Output() onSecondaryButtonClick = new EventEmitter(); @@ -632,6 +634,11 @@ export class InputPasswordComponent implements OnInit { this.formGroup.patchValue({ newPassword: await this.passwordGenerationService.generatePassword(options), }); + + if (!this.passwordStrengthComponent) { + throw new Error("PasswordStrengthComponent is not initialized"); + } + this.passwordStrengthComponent.updatePasswordStrength( this.formGroup.controls.newPassword.value, );