Skip to content

Commit

Permalink
refactor(email-verification-feature-flag): [PM-7882] Email Verificati…
Browse files Browse the repository at this point in the history
…on - Rolled back just a few more fixes.
  • Loading branch information
Patrick-Pimentel-Bitwarden committed Jan 6, 2025
1 parent 84edfc0 commit 763f903
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 25 deletions.
2 changes: 0 additions & 2 deletions apps/web/src/app/tools/send/access.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// FIXME: Update this file to be type safe and remove this and next line
// @ts-strict-ignore
import { Component, OnInit } from "@angular/core";
import { FormBuilder } from "@angular/forms";
import { ActivatedRoute } from "@angular/router";
Expand Down
39 changes: 16 additions & 23 deletions libs/angular/src/auth/components/login-v1.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ export class LoginComponentV1 extends CaptchaProtectedComponent implements OnIni
const errorText = this.getErrorToastMessage();
this.toastService.showToast({
variant: "error",
title: this.i18nService.t("errorOccurred"),
title: this.i18nService.t("errorOccured"),
message: errorText,
});
return;
Expand Down Expand Up @@ -223,16 +223,12 @@ export class LoginComponentV1 extends CaptchaProtectedComponent implements OnIni

togglePassword() {
this.showPassword = !this.showPassword;
const masterPasswordElement = document.getElementById("masterPassword");

if (masterPasswordElement) {
if (this.ngZone.isStable) {
masterPasswordElement.focus();
} else {
this.ngZone.onStable.pipe(take(1)).subscribe(() => masterPasswordElement.focus());
}
if (this.ngZone.isStable) {
document.getElementById("masterPassword").focus();
} else {
this.logService.warning("Element with ID 'masterPassword' not found.");
this.ngZone.onStable
.pipe(take(1))
.subscribe(() => document.getElementById("masterPassword").focus());
}
}

Expand All @@ -250,7 +246,7 @@ export class LoginComponentV1 extends CaptchaProtectedComponent implements OnIni

async launchSsoBrowser(clientId: string, ssoRedirectUri: string) {
// Save off email for SSO
await this.ssoLoginService.setSsoEmail(this.formGroup.controls.email.value);
await this.ssoLoginService.setSsoEmail(this.formGroup.value.email);

// Generate necessary sso params
const passwordOptions: any = {
Expand Down Expand Up @@ -292,11 +288,11 @@ export class LoginComponentV1 extends CaptchaProtectedComponent implements OnIni

async validateEmail() {
this.formGroup.controls.email.markAsTouched();
const emailValid = this.formGroup.controls.email.valid;
const emailValid = this.formGroup.get("email").valid;

if (emailValid) {
this.toggleValidateEmail(true);
await this.getLoginWithDevice(this.formGroup.controls.email.value);
await this.getLoginWithDevice(this.loggedEmail);
}
}

Expand Down Expand Up @@ -343,8 +339,8 @@ export class LoginComponentV1 extends CaptchaProtectedComponent implements OnIni
}

protected async saveEmailSettings() {
this.loginEmailService.setLoginEmail(this.formGroup.controls.email.value);
this.loginEmailService.setRememberEmail(this.formGroup.controls.rememberEmail.value);
this.loginEmailService.setLoginEmail(this.formGroup.value.email);
this.loginEmailService.setRememberEmail(this.formGroup.value.rememberEmail);
await this.loginEmailService.saveEmailSettings();
}

Expand All @@ -356,14 +352,14 @@ export class LoginComponentV1 extends CaptchaProtectedComponent implements OnIni

this.toastService.showToast({
variant: "error",
title: this.i18nService.t("errorOccurred"),
title: this.i18nService.t("errorOccured"),
message: this.i18nService.t("encryptionKeyMigrationRequired"),
});
return true;
}

private getErrorToastMessage(): string {
const error: AllValidationErrors | undefined = this.formValidationErrorService
private getErrorToastMessage() {
const error: AllValidationErrors = this.formValidationErrorService
.getFormValidationErrors(this.formGroup.controls)
.shift();

Expand All @@ -376,12 +372,9 @@ export class LoginComponentV1 extends CaptchaProtectedComponent implements OnIni
default:
return this.i18nService.t(this.errorTag(error));
}
} else {
this.logService.warning(
"formValidationErrorService produced no errors even when the form is invalid.",
);
return this.i18nService.t("errorOccurred");
}

return;
}

private errorTag(error: AllValidationErrors): string {
Expand Down

0 comments on commit 763f903

Please sign in to comment.