1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-12-21 16:18:28 +01:00

fix clear when account unavailable error (#9299)

* fix clear when account unavailable error
* remove explicit password history clear on logout
This commit is contained in:
✨ Audrey ✨ 2024-05-22 10:03:17 -04:00 committed by GitHub
parent 91ccb5ff93
commit 6ca836f31d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 21 additions and 6 deletions

View File

@ -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),

View File

@ -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);

View File

@ -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);

View File

@ -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(),
]);

View File

@ -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)),
);