1
0
mirror of https://github.com/bitwarden/browser synced 2026-02-10 05:30:01 +00:00

Revert changes to v1 components

This commit is contained in:
Alec Rippberger
2025-03-17 10:02:33 -05:00
parent 9f550915d0
commit 06273f3b2a
5 changed files with 2 additions and 66 deletions

View File

@@ -7,7 +7,6 @@ import { filter, first, takeUntil } from "rxjs/operators";
import { TwoFactorComponentV1 as BaseTwoFactorComponent } from "@bitwarden/angular/auth/components/two-factor-v1.component";
import { WINDOW } from "@bitwarden/angular/services/injection-tokens";
import { TwoFactorFormCacheService } from "@bitwarden/auth/angular";
import {
LoginStrategyServiceAbstraction,
LoginEmailServiceAbstraction,
@@ -68,7 +67,6 @@ export class TwoFactorComponentV1 extends BaseTwoFactorComponent implements OnIn
toastService: ToastService,
@Inject(WINDOW) protected win: Window,
private browserMessagingApi: ZonedMessageListenerService,
protected twoFactorFormCacheService: TwoFactorFormCacheService,
) {
super(
loginStrategyService,
@@ -90,7 +88,6 @@ export class TwoFactorComponentV1 extends BaseTwoFactorComponent implements OnIn
masterPasswordService,
accountService,
toastService,
twoFactorFormCacheService,
);
this.onSuccessfulLogin = async () => {
// FIXME: Verify that this floating promise is intentional. If it is, add an explanatory comment and ensure there is proper error handling.
@@ -130,18 +127,6 @@ export class TwoFactorComponentV1 extends BaseTwoFactorComponent implements OnIn
return;
}
// Load form data from cache if available
const cachedData = await this.twoFactorFormCacheService.getFormData();
if (cachedData?.token !== undefined) {
this.token = cachedData.token;
}
if (cachedData?.remember !== undefined) {
this.remember = cachedData.remember;
}
if (cachedData?.selectedProviderType !== undefined) {
this.selectedProviderType = cachedData.selectedProviderType;
}
await super.ngOnInit();
if (this.selectedProviderType == null) {
return;
@@ -155,8 +140,7 @@ export class TwoFactorComponentV1 extends BaseTwoFactorComponent implements OnIn
if (
this.selectedProviderType === TwoFactorProviderType.Email &&
BrowserPopupUtils.inPopup(window) &&
!(await this.configService.getFeatureFlag(FeatureFlag.PM9115_TwoFactorFormPersistence))
BrowserPopupUtils.inPopup(window)
) {
const confirmed = await this.dialogService.openSimpleDialog({
title: { key: "warning" },
@@ -203,15 +187,7 @@ export class TwoFactorComponentV1 extends BaseTwoFactorComponent implements OnIn
super.ngOnDestroy();
}
async anotherMethod() {
// Save form data to cache before navigating to another method
await this.twoFactorFormCacheService.saveFormData({
token: this.token,
remember: this.remember,
selectedProviderType: this.selectedProviderType,
emailSent: this.selectedProviderType === TwoFactorProviderType.Email,
});
anotherMethod() {
const sso = this.route.snapshot.queryParamMap.get("sso") === "true";
if (sso) {
@@ -281,24 +257,4 @@ export class TwoFactorComponentV1 extends BaseTwoFactorComponent implements OnIn
encodeURIComponent(JSON.stringify(duoHandOffMessage));
this.platformUtilsService.launchUri(launchUrl);
}
// Override the doSubmit to clear cached data on successful login
async doSubmit() {
await super.doSubmit();
await this.twoFactorFormCacheService.clearFormData();
}
/**
* Save the current form state to cache when inputs change
*/
async saveFormData() {
if (this.twoFactorFormCacheService) {
await this.twoFactorFormCacheService.saveFormData({
token: this.token,
remember: this.remember,
selectedProviderType: this.selectedProviderType,
emailSent: this.selectedProviderType === TwoFactorProviderType.Email,
});
}
}
}

View File

@@ -29,7 +29,6 @@ import { StateService } from "@bitwarden/common/platform/abstractions/state.serv
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
import { ToastService } from "@bitwarden/components";
import { DesktopTwoFactorFormCacheService } from "./services/desktop-two-factor-form-cache.service";
import { TwoFactorOptionsComponentV1 } from "./two-factor-options-v1.component";
const BroadcasterSubscriptionId = "TwoFactorComponent";
@@ -69,7 +68,6 @@ export class TwoFactorComponentV1 extends BaseTwoFactorComponent implements OnDe
accountService: AccountService,
toastService: ToastService,
@Inject(WINDOW) protected win: Window,
twoFactorFormCacheService: DesktopTwoFactorFormCacheService,
) {
super(
loginStrategyService,
@@ -91,7 +89,6 @@ export class TwoFactorComponentV1 extends BaseTwoFactorComponent implements OnDe
masterPasswordService,
accountService,
toastService,
twoFactorFormCacheService,
);
this.onSuccessfulLogin = async () => {
// FIXME: Verify that this floating promise is intentional. If it is, add an explanatory comment and ensure there is proper error handling.

View File

@@ -7,7 +7,6 @@ import { Subject, takeUntil, lastValueFrom } from "rxjs";
import { TwoFactorComponentV1 as BaseTwoFactorComponent } from "@bitwarden/angular/auth/components/two-factor-v1.component";
import { WINDOW } from "@bitwarden/angular/services/injection-tokens";
import { TwoFactorFormCacheService } from "@bitwarden/auth/angular";
import {
LoginStrategyServiceAbstraction,
LoginEmailServiceAbstraction,
@@ -74,7 +73,6 @@ export class TwoFactorComponentV1 extends BaseTwoFactorComponent implements OnIn
toastService: ToastService,
private formBuilder: FormBuilder,
@Inject(WINDOW) protected win: Window,
twoFactorFormCacheService: TwoFactorFormCacheService,
) {
super(
loginStrategyService,
@@ -96,7 +94,6 @@ export class TwoFactorComponentV1 extends BaseTwoFactorComponent implements OnIn
masterPasswordService,
accountService,
toastService,
twoFactorFormCacheService,
);
this.onSuccessfulLoginNavigate = this.goAfterLogIn;
}

View File

@@ -5,7 +5,6 @@ import { mock, MockProxy } from "jest-mock-extended";
import { BehaviorSubject } from "rxjs";
import { WINDOW } from "@bitwarden/angular/services/injection-tokens";
import { TwoFactorFormCacheService } from "@bitwarden/auth/angular";
import {
LoginStrategyServiceAbstraction,
LoginEmailServiceAbstraction,
@@ -73,7 +72,6 @@ describe("TwoFactorComponent", () => {
let mockMasterPasswordService: FakeMasterPasswordService;
let mockAccountService: FakeAccountService;
let mockToastService: MockProxy<ToastService>;
let mockTwoFactorFormCacheService: MockProxy<TwoFactorFormCacheService>;
let mockUserDecryptionOpts: {
noMasterPassword: UserDecryptionOptions;
@@ -110,11 +108,6 @@ describe("TwoFactorComponent", () => {
mockAccountService = mockAccountServiceWith(userId);
mockToastService = mock<ToastService>();
mockMasterPasswordService = new FakeMasterPasswordService();
mockTwoFactorFormCacheService = mock<TwoFactorFormCacheService>();
// Setup form cache service mock with necessary observables
mockTwoFactorFormCacheService.isEnabled$.mockReturnValue(new BehaviorSubject(false));
mockTwoFactorFormCacheService.formData$.mockReturnValue(new BehaviorSubject(null));
mockUserDecryptionOpts = {
noMasterPassword: new UserDecryptionOptions({
@@ -197,7 +190,6 @@ describe("TwoFactorComponent", () => {
{ provide: InternalMasterPasswordServiceAbstraction, useValue: mockMasterPasswordService },
{ provide: AccountService, useValue: mockAccountService },
{ provide: ToastService, useValue: mockToastService },
{ provide: TwoFactorFormCacheService, useValue: mockTwoFactorFormCacheService },
],
});

View File

@@ -7,7 +7,6 @@ import { firstValueFrom } from "rxjs";
import { first } from "rxjs/operators";
import { WINDOW } from "@bitwarden/angular/services/injection-tokens";
import { TwoFactorFormCacheService } from "@bitwarden/auth/angular";
import {
LoginStrategyServiceAbstraction,
LoginEmailServiceAbstraction,
@@ -100,7 +99,6 @@ export class TwoFactorComponentV1 extends CaptchaProtectedComponent implements O
protected masterPasswordService: InternalMasterPasswordServiceAbstraction,
protected accountService: AccountService,
protected toastService: ToastService,
protected twoFactorFormCacheService: TwoFactorFormCacheService,
) {
super(environmentService, i18nService, platformUtilsService, toastService);
@@ -439,10 +437,6 @@ export class TwoFactorComponentV1 extends CaptchaProtectedComponent implements O
return;
}
if ((await this.twoFactorFormCacheService.getFormData()).emailSent) {
return;
}
if ((await this.loginStrategyService.getEmail()) == null) {
this.toastService.showToast({
variant: "error",