1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-09-14 02:08:50 +02:00
bitwarden-browser/angular
Addison Beck 57d60bdfa6
Misc Account Switching Fixes & Refactors (#600)
* [refactor] Restructure EnvironmentUrls in state

* Patch up (add missing fields) and more extensivly use the EnvironmentUrls class instead of passing around an any
* Add environmentUrls to the AccountSettings model in addition to GlobalState for use in both scopes
* Move EnvironmentUrls initialization to the model level and out of StateSerice
* Adjust the StateMigrationService to account for these changes

* [refactor] Improve order of operations for LockGuardService

We currently jump through a bunch of hoops to verify users can access the Lock page, like checking authentication first.
If a user is not authenticated, they are not locked, so we can improve performance for the happy path of this serivice by checking isLocked first and using isAuthenticated to deviate from the normal flow if needed.

* [bug] Subscribe to State.accounts in EnvironmentService and set urls accordingly

The EnvironmentService has no context for account changes currently and does not update actively used urls based on active account.
This commit addresses this issue by subscribing to State.accounts and resetting the service's urls on account change.

* [bug] Clear AccessToken from State on clean

In order for logout flows to function as expected we need to deauthenticate users when cleaning up state before checking for the next active user
Otherwise the service will continue to think the user being logged out is active

* [refactor] Stop pushing accounts when modifying disk state

There is no reason to push new accounts to subscribers when updating disk state.
Subscribers recieve a copy of in memory state, so changes to disk will not be refelected and have to be fetched seperatly from the service.
Pushing when saving disk state is just creating an unecassary performance burden.

* [refactor] Default to in memory active user if availible, even when accessing disk state

Sometimes we need to pull activeUserId from storage to access a bit of data, like on initial boot, but most of the time this isn't necassary.
Since we pull this userId a lot, checking disk each time is a performance burden. Defaulting to the in memory user ID if avaible helps alleviate this.

* [style] Ran prettier

* [style] Change a let to a const
2022-01-07 09:30:54 -05:00
..
src Misc Account Switching Fixes & Refactors (#600) 2022-01-07 09:30:54 -05:00
package-lock.json Bump angular to 12. (#571) 2021-12-09 15:00:26 +01:00
package.json Bump angular to 12. (#571) 2021-12-09 15:00:26 +01:00
tsconfig.json Apply Prettier (#581) 2021-12-16 13:36:21 +01:00