diff --git a/apps/web/src/app/auth/hint.component.html b/apps/web/src/app/auth/hint.component.html index 786643d9470..9f4d76d8405 100644 --- a/apps/web/src/app/auth/hint.component.html +++ b/apps/web/src/app/auth/hint.component.html @@ -1,44 +1,23 @@ -
-
-
-

{{ "passwordHint" | i18n }}

-
-
-
- - - {{ "enterEmailToGetHint" | i18n }} -
-
-
- - - {{ "cancel" | i18n }} - -
-
-
-
+ + + {{ "emailAddress" | i18n }} + + {{ "enterEmailToGetHint" | i18n }} + +
+
+ + + {{ "cancel" | i18n }} +
diff --git a/apps/web/src/app/auth/hint.component.ts b/apps/web/src/app/auth/hint.component.ts index 116b0f3f830..91e9ca5cebb 100644 --- a/apps/web/src/app/auth/hint.component.ts +++ b/apps/web/src/app/auth/hint.component.ts @@ -1,4 +1,5 @@ import { Component } from "@angular/core"; +import { FormBuilder, Validators } from "@angular/forms"; import { Router } from "@angular/router"; import { HintComponent as BaseHintComponent } from "@bitwarden/angular/auth/components/hint.component"; @@ -13,6 +14,14 @@ import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/pl templateUrl: "hint.component.html", }) export class HintComponent extends BaseHintComponent { + formGroup = this.formBuilder.group({ + email: ["", [Validators.email, Validators.required]], + }); + + get emailFormControl() { + return this.formGroup.controls.email; + } + constructor( router: Router, i18nService: I18nService, @@ -20,7 +29,24 @@ export class HintComponent extends BaseHintComponent { platformUtilsService: PlatformUtilsService, logService: LogService, loginEmailService: LoginEmailServiceAbstraction, + private formBuilder: FormBuilder, ) { super(router, i18nService, apiService, platformUtilsService, logService, loginEmailService); } + + ngOnInit(): void { + super.ngOnInit(); + this.emailFormControl.setValue(this.email); + } + + // Wrapper method to call super.submit() since properties (e.g., submit) cannot use super directly + // This is because properties are assigned per type and generally don't have access to the prototype + async superSubmit() { + await super.submit(); + } + + submit = async () => { + this.email = this.emailFormControl.value; + await this.superSubmit(); + }; } diff --git a/apps/web/src/app/oss-routing.module.ts b/apps/web/src/app/oss-routing.module.ts index 7a57f7a1ce6..e7236348a6c 100644 --- a/apps/web/src/app/oss-routing.module.ts +++ b/apps/web/src/app/oss-routing.module.ts @@ -111,12 +111,6 @@ const routes: Routes = [ component: SetPasswordComponent, data: { titleId: "setMasterPassword" } satisfies DataProperties, }, - { - path: "hint", - component: HintComponent, - canActivate: [UnauthGuard], - data: { titleId: "passwordHint" } satisfies DataProperties, - }, { path: "lock", component: LockComponent, @@ -338,6 +332,25 @@ const routes: Routes = [ }, ], }, + { + path: "hint", + canActivate: [unauthGuardFn()], + children: [ + { + path: "", + component: HintComponent, + data: { + pageTitle: "passwordHint", + titleId: "passwordHint", + } satisfies DataProperties & AnonLayoutWrapperData, + }, + { + path: "", + component: EnvironmentSelectorComponent, + outlet: "environment-selector", + }, + ], + }, { path: "remove-password", component: RemovePasswordComponent,