From 4ede7f90564135da97c754b6b90b26a483cb6b98 Mon Sep 17 00:00:00 2001 From: Andreas Coroiu Date: Thu, 10 Apr 2025 13:19:12 +0200 Subject: [PATCH] feat: clear cached history after successfull login --- .../popup-login-success-handler.service.ts | 21 +++++++++++++++++++ .../src/popup/services/services.module.ts | 9 ++++++++ 2 files changed, 30 insertions(+) create mode 100644 apps/browser/src/auth/services/popup-login-success-handler.service.ts diff --git a/apps/browser/src/auth/services/popup-login-success-handler.service.ts b/apps/browser/src/auth/services/popup-login-success-handler.service.ts new file mode 100644 index 00000000000..ca32fceee3e --- /dev/null +++ b/apps/browser/src/auth/services/popup-login-success-handler.service.ts @@ -0,0 +1,21 @@ +import { DefaultLoginSuccessHandlerService } from "@bitwarden/auth/common"; +import { SyncService } from "@bitwarden/common/platform/sync"; +import { UserId } from "@bitwarden/common/types/guid"; +import { UserAsymmetricKeysRegenerationService } from "@bitwarden/key-management"; + +import { PopupRouterCacheService } from "../../platform/popup/view-cache/popup-router-cache.service"; + +export class PopupLoginSuccessHandlerService extends DefaultLoginSuccessHandlerService { + constructor( + syncService: SyncService, + userAsymmetricKeysRegenerationService: UserAsymmetricKeysRegenerationService, + private popupRouterCacheService: PopupRouterCacheService, + ) { + super(syncService, userAsymmetricKeysRegenerationService); + } + + async run(userId: UserId): Promise { + await this.popupRouterCacheService.setHistory([]); + await super.run(userId); + } +} diff --git a/apps/browser/src/popup/services/services.module.ts b/apps/browser/src/popup/services/services.module.ts index 1c907f18f83..829930c4fac 100644 --- a/apps/browser/src/popup/services/services.module.ts +++ b/apps/browser/src/popup/services/services.module.ts @@ -35,6 +35,7 @@ import { import { LockService, LoginEmailService, + LoginSuccessHandlerService, PinServiceAbstraction, SsoUrlService, } from "@bitwarden/auth/common"; @@ -129,6 +130,7 @@ import { DefaultKeyService, KdfConfigService, KeyService, + UserAsymmetricKeysRegenerationService, } from "@bitwarden/key-management"; import { LockComponentService } from "@bitwarden/key-management-ui"; import { @@ -146,6 +148,7 @@ import { ExtensionTwoFactorAuthComponentService } from "../../auth/services/exte import { ExtensionTwoFactorAuthDuoComponentService } from "../../auth/services/extension-two-factor-auth-duo-component.service"; import { ExtensionTwoFactorAuthEmailComponentService } from "../../auth/services/extension-two-factor-auth-email-component.service"; import { ExtensionTwoFactorAuthWebAuthnComponentService } from "../../auth/services/extension-two-factor-auth-webauthn-component.service"; +import { PopupLoginSuccessHandlerService } from "../../auth/services/popup-login-success-handler.service"; import { AutofillService as AutofillServiceAbstraction } from "../../autofill/services/abstractions/autofill.service"; import AutofillService from "../../autofill/services/autofill.service"; import { InlineMenuFieldQualificationService } from "../../autofill/services/inline-menu-field-qualification.service"; @@ -163,6 +166,7 @@ import { OffscreenDocumentService } from "../../platform/offscreen-document/abst import { DefaultOffscreenDocumentService } from "../../platform/offscreen-document/offscreen-document.service"; import { PopupCompactModeService } from "../../platform/popup/layout/popup-compact-mode.service"; import { BrowserFileDownloadService } from "../../platform/popup/services/browser-file-download.service"; +import { PopupRouterCacheService } from "../../platform/popup/view-cache/popup-router-cache.service"; import { PopupViewCacheService } from "../../platform/popup/view-cache/popup-view-cache.service"; import { ScriptInjectorService } from "../../platform/services/abstractions/script-injector.service"; import { BrowserEnvironmentService } from "../../platform/services/browser-environment.service"; @@ -667,6 +671,11 @@ const safeProviders: SafeProvider[] = [ useClass: ForegroundNotificationsService, deps: [LogService], }), + safeProvider({ + provide: LoginSuccessHandlerService, + useClass: PopupLoginSuccessHandlerService, + deps: [SyncService, UserAsymmetricKeysRegenerationService, PopupRouterCacheService], + }), ]; @NgModule({