mirror of
https://github.com/bitwarden/browser
synced 2025-12-11 13:53:34 +00:00
* Use typescript-strict-plugin to iteratively turn on strict * Add strict testing to pipeline Can be executed locally through either `npm run test:types` for full type checking including spec files, or `npx tsc-strict` for only tsconfig.json included files. * turn on strict for scripts directory * Use plugin for all tsconfigs in monorepo vscode is capable of executing tsc with plugins, but uses the most relevant tsconfig to do so. If the plugin is not a part of that config, it is skipped and developers get no feedback of strict compile time issues. These updates remedy that at the cost of slightly more complex removal of the plugin when the time comes. * remove plugin from configs that extend one that already has it * Update workspace settings to honor strict plugin * Apply strict-plugin to native message test runner * Update vscode workspace to use root tsc version * `./node_modules/.bin/update-strict-comments` 🤖 This is a one-time operation. All future files should adhere to strict type checking. * Add fixme to `ts-strict-ignore` comments * `update-strict-comments` 🤖 repeated for new merge files
78 lines
2.4 KiB
TypeScript
78 lines
2.4 KiB
TypeScript
// FIXME: Update this file to be type safe and remove this and next line
|
|
// @ts-strict-ignore
|
|
import { Directive } from "@angular/core";
|
|
import { FormBuilder } from "@angular/forms";
|
|
|
|
import { UserVerificationService } from "@bitwarden/common/auth/abstractions/user-verification/user-verification.service.abstraction";
|
|
import { Verification } from "@bitwarden/common/auth/types/verification";
|
|
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
|
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
|
import { ToastService } from "@bitwarden/components";
|
|
|
|
import { ModalRef } from "../../components/modal/modal.ref";
|
|
|
|
export interface UserVerificationPromptParams {
|
|
confirmDescription: string;
|
|
confirmButtonText: string;
|
|
modalTitle: string;
|
|
}
|
|
|
|
/**
|
|
* Used to verify the user's identity (using their master password or email-based OTP for Key Connector users). You can customize all of the text in the modal.
|
|
* @deprecated Jan 24, 2024: Use new libs/auth UserVerificationDialogComponent instead.
|
|
*/
|
|
@Directive()
|
|
export class UserVerificationPromptComponent {
|
|
confirmDescription = this.config.confirmDescription;
|
|
confirmButtonText = this.config.confirmButtonText;
|
|
modalTitle = this.config.modalTitle;
|
|
|
|
formGroup = this.formBuilder.group({
|
|
secret: this.formBuilder.control<Verification | null>(null),
|
|
});
|
|
|
|
protected invalidSecret = false;
|
|
|
|
constructor(
|
|
private modalRef: ModalRef,
|
|
protected config: UserVerificationPromptParams,
|
|
protected userVerificationService: UserVerificationService,
|
|
private formBuilder: FormBuilder,
|
|
private platformUtilsService: PlatformUtilsService,
|
|
private i18nService: I18nService,
|
|
private toastService: ToastService,
|
|
) {}
|
|
|
|
get secret() {
|
|
return this.formGroup.controls.secret;
|
|
}
|
|
|
|
submit = async () => {
|
|
this.formGroup.markAllAsTouched();
|
|
|
|
if (this.formGroup.invalid) {
|
|
return;
|
|
}
|
|
|
|
try {
|
|
//Incorrect secret will throw an invalid password error.
|
|
await this.userVerificationService.verifyUser(this.secret.value);
|
|
this.invalidSecret = false;
|
|
} catch (e) {
|
|
this.invalidSecret = true;
|
|
this.toastService.showToast({
|
|
variant: "error",
|
|
title: this.i18nService.t("error"),
|
|
message: e.message,
|
|
});
|
|
return;
|
|
}
|
|
|
|
this.close(true);
|
|
};
|
|
|
|
close(success: boolean) {
|
|
this.modalRef.close(success);
|
|
}
|
|
}
|