diff --git a/angular/src/components/password-reprompt.component.ts b/angular/src/components/password-reprompt.component.ts index 1220f55533..03b4080277 100644 --- a/angular/src/components/password-reprompt.component.ts +++ b/angular/src/components/password-reprompt.component.ts @@ -6,6 +6,10 @@ import { PlatformUtilsService } from "jslib-common/abstractions/platformUtils.se import { ModalRef } from "./modal/modal.ref"; +/** + * Used to verify the user's Master Password for the "Master Password Re-prompt" feature only. + * See UserVerificationComponent for any other situation where you need to verify the user's identity. + */ @Directive() export class PasswordRepromptComponent { showPassword = false; diff --git a/angular/src/components/verify-master-password.component.html b/angular/src/components/user-verification.component.html similarity index 100% rename from angular/src/components/verify-master-password.component.html rename to angular/src/components/user-verification.component.html diff --git a/angular/src/components/verify-master-password.component.ts b/angular/src/components/user-verification.component.ts similarity index 76% rename from angular/src/components/verify-master-password.component.ts rename to angular/src/components/user-verification.component.ts index 45a6158123..5504796e4b 100644 --- a/angular/src/components/verify-master-password.component.ts +++ b/angular/src/components/user-verification.component.ts @@ -7,14 +7,20 @@ import { UserVerificationService } from "jslib-common/abstractions/userVerificat import { VerificationType } from "jslib-common/enums/verificationType"; import { Verification } from "jslib-common/types/verification"; +/** + * Used for general-purpose user verification throughout the app. + * Collects the user's master password, or if they are using Key Connector, prompts for an OTP via email. + * This is exposed to the parent component via the ControlValueAccessor interface (e.g. bind it to a FormControl). + * Use UserVerificationService to verify the user's input. + */ @Component({ - selector: "app-verify-master-password", - templateUrl: "verify-master-password.component.html", + selector: "app-user-verification", + templateUrl: "user-verification.component.html", providers: [ { provide: NG_VALUE_ACCESSOR, multi: true, - useExisting: VerifyMasterPasswordComponent, + useExisting: UserVerificationComponent, }, ], animations: [ @@ -23,7 +29,7 @@ import { Verification } from "jslib-common/types/verification"; ]), ], }) -export class VerifyMasterPasswordComponent implements ControlValueAccessor, OnInit { +export class UserVerificationComponent implements ControlValueAccessor, OnInit { usesKeyConnector = false; disableRequestOTP = false; sentCode = false; @@ -41,7 +47,7 @@ export class VerifyMasterPasswordComponent implements ControlValueAccessor, OnIn this.usesKeyConnector = await this.keyConnectorService.getUsesKeyConnector(); this.processChanges(this.secret.value); - this.secret.valueChanges.subscribe((secret) => this.processChanges(secret)); + this.secret.valueChanges.subscribe((secret: string) => this.processChanges(secret)); } async requestOTP() { diff --git a/angular/src/directives/api-action.directive.ts b/angular/src/directives/api-action.directive.ts index 357cefb4ed..3d12172603 100644 --- a/angular/src/directives/api-action.directive.ts +++ b/angular/src/directives/api-action.directive.ts @@ -5,6 +5,12 @@ import { ErrorResponse } from "jslib-common/models/response/errorResponse"; import { ValidationService } from "../services/validation.service"; +/** + * Provides error handling, in particular for any error returned by the server in an api call. + * Attach it to a