1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-12-22 16:29:09 +01:00

Handle active user not logged in (#6692)

This occurs when all users are logged out, we use the last logged in
user as the active user to indicate which settings should be loaded by
default.
This commit is contained in:
Matt Gibson 2023-10-25 07:48:34 -04:00 committed by GitHub
parent 7fd102c15c
commit 67bc8d591f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -173,7 +173,18 @@ export class StateService<
await this.pushAccounts(); await this.pushAccounts();
this.activeAccountSubject.next(state.activeUserId); this.activeAccountSubject.next(state.activeUserId);
// TODO: Temporary update to avoid routing all account status changes through account service for now. // TODO: Temporary update to avoid routing all account status changes through account service for now.
// account service tracks logged out accounts, but State service does not, so we need to add the active account
// if it's not in the accounts list.
if (this.accountsSubject.value[state.activeUserId] == null) {
const activeDiskAccount = await this.getAccountFromDisk({ userId: state.activeUserId });
this.accountService.addAccount(state.activeUserId as UserId, {
name: activeDiskAccount.profile.name,
email: activeDiskAccount.profile.email,
status: AuthenticationStatus.LoggedOut,
});
}
this.accountService.switchAccount(state.activeUserId as UserId); this.accountService.switchAccount(state.activeUserId as UserId);
// End TODO
return state; return state;
}); });