mirror of
https://github.com/bitwarden/browser
synced 2025-12-19 17:53:39 +00:00
* [deps] Autofill: Update prettier to v3 * prettier formatting updates --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Jonathan Prusik <jprusik@classynemesis.com>
77 lines
1.9 KiB
TypeScript
77 lines
1.9 KiB
TypeScript
import { DIALOG_DATA, DialogRef } from "@angular/cdk/dialog";
|
|
import { CommonModule } from "@angular/common";
|
|
import { Component, Inject } from "@angular/core";
|
|
import { FormControl, FormGroup, ReactiveFormsModule, Validators } from "@angular/forms";
|
|
|
|
import { JslibModule } from "@bitwarden/angular/jslib.module";
|
|
import {
|
|
AsyncActionsModule,
|
|
ButtonModule,
|
|
DialogModule,
|
|
DialogService,
|
|
FormFieldModule,
|
|
IconButtonModule,
|
|
TypographyModule,
|
|
} from "@bitwarden/components";
|
|
|
|
export type LastPassMultifactorPromptVariant = "otp" | "oob" | "yubikey";
|
|
|
|
type LastPassMultifactorPromptData = {
|
|
variant: LastPassMultifactorPromptVariant;
|
|
};
|
|
|
|
@Component({
|
|
templateUrl: "lastpass-multifactor-prompt.component.html",
|
|
standalone: true,
|
|
imports: [
|
|
CommonModule,
|
|
JslibModule,
|
|
ReactiveFormsModule,
|
|
DialogModule,
|
|
FormFieldModule,
|
|
AsyncActionsModule,
|
|
ButtonModule,
|
|
IconButtonModule,
|
|
TypographyModule,
|
|
],
|
|
})
|
|
export class LastPassMultifactorPromptComponent {
|
|
private variant = this.data.variant;
|
|
|
|
protected get descriptionI18nKey(): string {
|
|
switch (this.variant) {
|
|
case "oob":
|
|
return "lastPassOOBDesc";
|
|
case "yubikey":
|
|
return "lastPassYubikeyDesc";
|
|
case "otp":
|
|
default:
|
|
return "lastPassMFADesc";
|
|
}
|
|
}
|
|
|
|
protected formGroup = new FormGroup({
|
|
passcode: new FormControl("", {
|
|
validators: Validators.required,
|
|
updateOn: "submit",
|
|
}),
|
|
});
|
|
|
|
constructor(
|
|
public dialogRef: DialogRef,
|
|
@Inject(DIALOG_DATA) protected data: LastPassMultifactorPromptData,
|
|
) {}
|
|
|
|
submit = () => {
|
|
this.formGroup.markAsTouched();
|
|
if (!this.formGroup.valid) {
|
|
return;
|
|
}
|
|
this.dialogRef.close(this.formGroup.value.passcode);
|
|
};
|
|
|
|
static open(dialogService: DialogService, data: LastPassMultifactorPromptData) {
|
|
return dialogService.open<string>(LastPassMultifactorPromptComponent, { data });
|
|
}
|
|
}
|