From 6df52262a94ba3c1a0e318417ede0388518244be Mon Sep 17 00:00:00 2001 From: Addison Beck Date: Fri, 5 Apr 2024 13:10:55 -0500 Subject: [PATCH] Clear provider state on logout (#8563) --- apps/browser/src/background/main.background.ts | 1 - apps/cli/src/bw.ts | 1 - apps/desktop/src/app/app.component.ts | 1 - libs/common/src/admin-console/services/provider.service.ts | 5 +++-- 4 files changed, 3 insertions(+), 5 deletions(-) diff --git a/apps/browser/src/background/main.background.ts b/apps/browser/src/background/main.background.ts index 235ccdf1aa..31f0ae7279 100644 --- a/apps/browser/src/background/main.background.ts +++ b/apps/browser/src/background/main.background.ts @@ -1143,7 +1143,6 @@ export default class MainBackground { this.vaultTimeoutSettingsService.clear(userId), this.vaultFilterService.clear(), this.biometricStateService.logout(userId), - this.providerService.save(null, userId), /* We intentionally do not clear: * - autofillSettingsService * - badgeSettingsService diff --git a/apps/cli/src/bw.ts b/apps/cli/src/bw.ts index 08d43a88ef..0e6571f775 100644 --- a/apps/cli/src/bw.ts +++ b/apps/cli/src/bw.ts @@ -703,7 +703,6 @@ export class Main { this.folderService.clear(userId), this.collectionService.clear(userId as UserId), this.passwordGenerationService.clear(), - this.providerService.save(null, userId as UserId), ]); await this.stateEventRunnerService.handleEvent("logout", userId as UserId); diff --git a/apps/desktop/src/app/app.component.ts b/apps/desktop/src/app/app.component.ts index 71b272b897..884296ea29 100644 --- a/apps/desktop/src/app/app.component.ts +++ b/apps/desktop/src/app/app.component.ts @@ -584,7 +584,6 @@ export class AppComponent implements OnInit, OnDestroy { await this.passwordGenerationService.clear(userBeingLoggedOut); await this.vaultTimeoutSettingsService.clear(userBeingLoggedOut); await this.biometricStateService.logout(userBeingLoggedOut as UserId); - await this.providerService.save(null, userBeingLoggedOut as UserId); await this.stateEventRunnerService.handleEvent("logout", userBeingLoggedOut as UserId); diff --git a/libs/common/src/admin-console/services/provider.service.ts b/libs/common/src/admin-console/services/provider.service.ts index 47291a5520..064e0c7175 100644 --- a/libs/common/src/admin-console/services/provider.service.ts +++ b/libs/common/src/admin-console/services/provider.service.ts @@ -1,13 +1,14 @@ import { Observable, map, firstValueFrom, of, switchMap, take } from "rxjs"; -import { KeyDefinition, PROVIDERS_DISK, StateProvider } from "../../platform/state"; +import { UserKeyDefinition, PROVIDERS_DISK, StateProvider } from "../../platform/state"; import { UserId } from "../../types/guid"; import { ProviderService as ProviderServiceAbstraction } from "../abstractions/provider.service"; import { ProviderData } from "../models/data/provider.data"; import { Provider } from "../models/domain/provider"; -export const PROVIDERS = KeyDefinition.record(PROVIDERS_DISK, "providers", { +export const PROVIDERS = UserKeyDefinition.record(PROVIDERS_DISK, "providers", { deserializer: (obj: ProviderData) => obj, + clearOn: ["logout"], }); function mapToSingleProvider(providerId: string) {