diff --git a/apps/browser/src/background/main.background.ts b/apps/browser/src/background/main.background.ts index 90a018a8fe8..a382a76781a 100644 --- a/apps/browser/src/background/main.background.ts +++ b/apps/browser/src/background/main.background.ts @@ -1321,7 +1321,6 @@ export default class MainBackground { this.cipherService.clear(userBeingLoggedOut), this.folderService.clear(userBeingLoggedOut), this.collectionService.clear(userBeingLoggedOut), - this.passwordGenerationService.clear(userBeingLoggedOut), this.vaultTimeoutSettingsService.clear(userBeingLoggedOut), this.vaultFilterService.clear(), this.biometricStateService.logout(userBeingLoggedOut), diff --git a/apps/cli/src/service-container.ts b/apps/cli/src/service-container.ts index a47a943724f..882791ef9c9 100644 --- a/apps/cli/src/service-container.ts +++ b/apps/cli/src/service-container.ts @@ -740,7 +740,6 @@ export class ServiceContainer { this.cipherService.clear(userId), this.folderService.clear(userId), this.collectionService.clear(userId as UserId), - this.passwordGenerationService.clear(), ]); await this.stateEventRunnerService.handleEvent("logout", userId); diff --git a/apps/desktop/src/app/app.component.ts b/apps/desktop/src/app/app.component.ts index 901d7a9c5cc..4bc34f9af97 100644 --- a/apps/desktop/src/app/app.component.ts +++ b/apps/desktop/src/app/app.component.ts @@ -608,7 +608,6 @@ export class AppComponent implements OnInit, OnDestroy { await this.cipherService.clear(userBeingLoggedOut); await this.folderService.clear(userBeingLoggedOut); await this.collectionService.clear(userBeingLoggedOut); - await this.passwordGenerationService.clear(userBeingLoggedOut); await this.vaultTimeoutSettingsService.clear(userBeingLoggedOut); await this.biometricStateService.logout(userBeingLoggedOut); diff --git a/apps/web/src/app/app.component.ts b/apps/web/src/app/app.component.ts index 7d2b6d999aa..6c71309243e 100644 --- a/apps/web/src/app/app.component.ts +++ b/apps/web/src/app/app.component.ts @@ -300,7 +300,6 @@ export class AppComponent implements OnDestroy, OnInit { this.cipherService.clear(userId), this.folderService.clear(userId), this.collectionService.clear(userId), - this.passwordGenerationService.clear(), this.biometricStateService.logout(userId), this.paymentMethodWarningService.clear(), ]); diff --git a/libs/common/src/tools/generator/legacy-password-generation.service.ts b/libs/common/src/tools/generator/legacy-password-generation.service.ts index 74b2ab46e6b..db4aa9d2a99 100644 --- a/libs/common/src/tools/generator/legacy-password-generation.service.ts +++ b/libs/common/src/tools/generator/legacy-password-generation.service.ts @@ -8,6 +8,8 @@ import { of, concat, Observable, + filter, + timeout, } from "rxjs"; import { PolicyService } from "../../admin-console/abstractions/policy/policy.service.abstraction"; @@ -382,6 +384,13 @@ export class LegacyPasswordGenerationService implements PasswordGenerationServic getHistory() { const history = this.accountService.activeAccount$.pipe( concatMap((account) => this.history.credentials$(account.id)), + timeout({ + // timeout after 1 second + each: 1000, + with() { + return []; + }, + }), map((history) => history.map(toGeneratedPasswordHistory)), ); @@ -390,13 +399,23 @@ export class LegacyPasswordGenerationService implements PasswordGenerationServic async addHistory(password: string) { const account = await firstValueFrom(this.accountService.activeAccount$); - // legacy service doesn't distinguish credential types - await this.history.track(account.id, password, "password"); + if (account?.id) { + // legacy service doesn't distinguish credential types + await this.history.track(account.id, password, "password"); + } } clear() { const history$ = this.accountService.activeAccount$.pipe( + filter((account) => !!account?.id), concatMap((account) => this.history.clear(account.id)), + timeout({ + // timeout after 1 second + each: 1000, + with() { + return []; + }, + }), map((history) => history.map(toGeneratedPasswordHistory)), );