1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-18 17:23:37 +00:00
Files
browser/apps/web/src/app/auth/lock.component.ts
Oscar Hinton 7dfef8991c [PM-1935] Migrate vault lock screen to component library (#6237)
* Migrate vault lock screen to component library

* Remove unnecessary divs

* Remove card from trial

* Migrate to standalone component

* refactor to use AnonLayout

* revert login component

* migrate web component to bitSubmit

* remove class

* use inject

* update web pageTitle translation

* validate on submit, not on blur

---------

Co-authored-by: rr-bw <102181210+rr-bw@users.noreply.github.com>
2024-07-09 17:19:12 -07:00

50 lines
1.2 KiB
TypeScript

import { Component, inject } from "@angular/core";
import { FormBuilder, Validators } from "@angular/forms";
import { LockComponent as BaseLockComponent } from "@bitwarden/angular/auth/components/lock.component";
import { SharedModule } from "../shared";
@Component({
selector: "app-lock",
templateUrl: "lock.component.html",
standalone: true,
imports: [SharedModule],
})
export class LockComponent extends BaseLockComponent {
formBuilder = inject(FormBuilder);
formGroup = this.formBuilder.group({
masterPassword: ["", { validators: Validators.required, updateOn: "submit" }],
});
get masterPasswordFormControl() {
return this.formGroup.controls.masterPassword;
}
async ngOnInit() {
await super.ngOnInit();
this.masterPasswordFormControl.setValue(this.masterPassword);
this.onSuccessfulSubmit = async () => {
await this.router.navigateByUrl(this.successRoute);
};
}
async superSubmit() {
await super.submit();
}
submit = async () => {
this.formGroup.markAllAsTouched();
if (this.formGroup.invalid) {
return;
}
this.masterPassword = this.masterPasswordFormControl.value;
await this.superSubmit();
};
}