mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-06 09:20:43 +01:00
Clear active user if state has no users (#677)
* Clear active user if state has no users * use the correct userId * run prettier * add null check
This commit is contained in:
parent
3a1b5bf9a0
commit
bcbb52e6ec
@ -2376,26 +2376,24 @@ export class StateService<
|
|||||||
protected async removeAccountFromLocalStorage(
|
protected async removeAccountFromLocalStorage(
|
||||||
userId: string = this.state.activeUserId
|
userId: string = this.state.activeUserId
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const storedAccount = await this.storageService.get<TAccount>(userId, {
|
const storedAccount = await this.getAccount(
|
||||||
htmlStorageLocation: HtmlStorageLocation.Local,
|
this.reconcileOptions({ userId: userId }, await this.defaultOnDiskLocalOptions())
|
||||||
});
|
);
|
||||||
await this.storageService.save(
|
await this.saveAccount(
|
||||||
userId,
|
|
||||||
this.resetAccount(storedAccount),
|
this.resetAccount(storedAccount),
|
||||||
await this.defaultOnDiskLocalOptions()
|
this.reconcileOptions({ userId: userId }, await this.defaultOnDiskLocalOptions())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async removeAccountFromSessionStorage(
|
protected async removeAccountFromSessionStorage(
|
||||||
userId: string = this.state.activeUserId
|
userId: string = this.state.activeUserId
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const storedAccount = await this.storageService.get<TAccount>(userId, {
|
const storedAccount = await this.getAccount(
|
||||||
htmlStorageLocation: HtmlStorageLocation.Session,
|
this.reconcileOptions({ userId: userId }, await this.defaultOnDiskOptions())
|
||||||
});
|
);
|
||||||
await this.storageService.save(
|
await this.saveAccount(
|
||||||
userId,
|
|
||||||
this.resetAccount(storedAccount),
|
this.resetAccount(storedAccount),
|
||||||
await this.defaultOnDiskOptions()
|
this.reconcileOptions({ userId: userId }, await this.defaultOnDiskOptions())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2470,6 +2468,10 @@ export class StateService<
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected async dynamicallySetActiveUser() {
|
protected async dynamicallySetActiveUser() {
|
||||||
|
if (this.state.accounts == null || Object.keys(this.state.accounts).length < 1) {
|
||||||
|
await this.setActiveUser(null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
for (const userId in this.state.accounts) {
|
for (const userId in this.state.accounts) {
|
||||||
if (userId == null) {
|
if (userId == null) {
|
||||||
continue;
|
continue;
|
||||||
|
Loading…
Reference in New Issue
Block a user