1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-26 12:25:20 +01:00

Clean up the cached account (#672)

* Clean up the cached account

* PR feedback: Avoid duplicate code
This commit is contained in:
Daniel James Smith 2022-02-11 14:06:40 +01:00 committed by GitHub
parent fd0410ca4b
commit eaf387435f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2425,13 +2425,14 @@ export class StateService<
protected removeAccountFromMemory(userId: string = this.state.activeUserId): void {
delete this.state.accounts[userId];
this.accountDiskCache.delete(userId);
}
protected async pruneInMemoryAccounts() {
// We preserve settings for logged out accounts, but we don't want to consider them when thinking about active account state
for (const userId in this.state.accounts) {
if (!(await this.getIsAuthenticated({ userId: userId }))) {
delete this.state.accounts[userId];
this.removeAccountFromMemory(userId);
}
}
}