1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-10 21:33:27 +00: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
5 changed files with 21 additions and 6 deletions

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