1
0
mirror of https://github.com/bitwarden/jslib synced 2025-12-15 15:53:51 +00: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

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