mirror of
https://github.com/bitwarden/browser
synced 2025-12-16 00:03:56 +00:00
Migrate provider service to state provider (#8173)
* Migrate existing provider data to StateProvider Migrate existing provider data to StateProvider * Rework the ProviderService to call StateProvider * Unit test the ProviderService * Update DI to reflect ProviderService's new args * Add ProviderService to logout chains across products * Remove provider related stateService methods * Update libs/common/src/state-migrations/migrations/28-move-provider-state-to-state-provider.spec.ts Co-authored-by: Justin Baur <19896123+justindbaur@users.noreply.github.com> * Cover up a copy/paste job * Compare equality over entire array in a test --------- Co-authored-by: Justin Baur <19896123+justindbaur@users.noreply.github.com>
This commit is contained in:
@@ -700,7 +700,7 @@ export default class MainBackground {
|
||||
this.fileUploadService,
|
||||
this.sendService,
|
||||
);
|
||||
this.providerService = new ProviderService(this.stateService);
|
||||
this.providerService = new ProviderService(this.stateProvider);
|
||||
this.syncService = new SyncService(
|
||||
this.apiService,
|
||||
this.settingsService,
|
||||
@@ -1114,12 +1114,12 @@ export default class MainBackground {
|
||||
this.keyConnectorService.clear(),
|
||||
this.vaultFilterService.clear(),
|
||||
this.biometricStateService.logout(userId),
|
||||
/*
|
||||
We intentionally do not clear:
|
||||
- autofillSettingsService
|
||||
- badgeSettingsService
|
||||
- userNotificationSettingsService
|
||||
*/
|
||||
this.providerService.save(null, userId),
|
||||
/* We intentionally do not clear:
|
||||
* - autofillSettingsService
|
||||
* - badgeSettingsService
|
||||
* - userNotificationSettingsService
|
||||
*/
|
||||
]);
|
||||
|
||||
//Needs to be checked before state is cleaned
|
||||
|
||||
@@ -24,7 +24,6 @@ import { VaultTimeoutSettingsService } from "@bitwarden/common/abstractions/vaul
|
||||
import { VaultTimeoutService } from "@bitwarden/common/abstractions/vault-timeout/vault-timeout.service";
|
||||
import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
|
||||
import { PolicyService } from "@bitwarden/common/admin-console/abstractions/policy/policy.service.abstraction";
|
||||
import { ProviderService } from "@bitwarden/common/admin-console/abstractions/provider.service";
|
||||
import { AccountService as AccountServiceAbstraction } from "@bitwarden/common/auth/abstractions/account.service";
|
||||
import { AuthService as AuthServiceAbstraction } from "@bitwarden/common/auth/abstractions/auth.service";
|
||||
import { DeviceTrustCryptoServiceAbstraction } from "@bitwarden/common/auth/abstractions/device-trust-crypto.service.abstraction";
|
||||
@@ -436,11 +435,6 @@ function getBgService<T>(service: keyof MainBackground) {
|
||||
AccountServiceAbstraction,
|
||||
],
|
||||
},
|
||||
{
|
||||
provide: ProviderService,
|
||||
useFactory: getBgService<ProviderService>("providerService"),
|
||||
deps: [],
|
||||
},
|
||||
{
|
||||
provide: SECURE_STORAGE,
|
||||
useFactory: getBgService<AbstractStorageService>("secureStorageService"),
|
||||
|
||||
@@ -388,7 +388,7 @@ export class Main {
|
||||
this.stateProvider,
|
||||
);
|
||||
|
||||
this.providerService = new ProviderService(this.stateService);
|
||||
this.providerService = new ProviderService(this.stateProvider);
|
||||
|
||||
this.organizationService = new OrganizationService(this.stateService, this.stateProvider);
|
||||
|
||||
@@ -655,6 +655,7 @@ export class Main {
|
||||
this.collectionService.clear(userId as UserId),
|
||||
this.policyService.clear(userId),
|
||||
this.passwordGenerationService.clear(),
|
||||
this.providerService.save(null, userId as UserId),
|
||||
]);
|
||||
|
||||
await this.stateEventRunnerService.handleEvent("logout", userId as UserId);
|
||||
|
||||
@@ -23,6 +23,7 @@ import { SettingsService } from "@bitwarden/common/abstractions/settings.service
|
||||
import { VaultTimeoutSettingsService } from "@bitwarden/common/abstractions/vault-timeout/vault-timeout-settings.service";
|
||||
import { VaultTimeoutService } from "@bitwarden/common/abstractions/vault-timeout/vault-timeout.service";
|
||||
import { InternalPolicyService } from "@bitwarden/common/admin-console/abstractions/policy/policy.service.abstraction";
|
||||
import { ProviderService } from "@bitwarden/common/admin-console/abstractions/provider.service";
|
||||
import { AuthService } from "@bitwarden/common/auth/abstractions/auth.service";
|
||||
import { KeyConnectorService } from "@bitwarden/common/auth/abstractions/key-connector.service";
|
||||
import { UserVerificationService } from "@bitwarden/common/auth/abstractions/user-verification/user-verification.service.abstraction";
|
||||
@@ -151,6 +152,7 @@ export class AppComponent implements OnInit, OnDestroy {
|
||||
private dialogService: DialogService,
|
||||
private biometricStateService: BiometricStateService,
|
||||
private stateEventRunnerService: StateEventRunnerService,
|
||||
private providerService: ProviderService,
|
||||
) {}
|
||||
|
||||
ngOnInit() {
|
||||
@@ -584,6 +586,7 @@ export class AppComponent implements OnInit, OnDestroy {
|
||||
await this.policyService.clear(userBeingLoggedOut);
|
||||
await this.keyConnectorService.clear();
|
||||
await this.biometricStateService.logout(userBeingLoggedOut as UserId);
|
||||
await this.providerService.save(null, userBeingLoggedOut as UserId);
|
||||
|
||||
await this.stateEventRunnerService.handleEvent("logout", userBeingLoggedOut as UserId);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user