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:
@@ -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,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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 },
|
||||
],
|
||||
});
|
||||
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user