mirror of
https://github.com/bitwarden/browser
synced 2026-02-09 13:10:17 +00:00
moving message sending side effect to sync
This commit is contained in:
@@ -743,7 +743,6 @@ export default class MainBackground {
|
||||
this.keyGenerationService,
|
||||
logoutCallback,
|
||||
this.stateProvider,
|
||||
this.messagingService,
|
||||
);
|
||||
|
||||
const sdkClientFactory = flagEnabled("sdk")
|
||||
|
||||
@@ -573,7 +573,6 @@ export class ServiceContainer {
|
||||
this.keyGenerationService,
|
||||
logoutCallback,
|
||||
this.stateProvider,
|
||||
this.messagingService,
|
||||
);
|
||||
|
||||
this.twoFactorService = new TwoFactorService(
|
||||
|
||||
@@ -987,7 +987,6 @@ const safeProviders: SafeProvider[] = [
|
||||
KeyGenerationServiceAbstraction,
|
||||
LOGOUT_CALLBACK,
|
||||
StateProvider,
|
||||
MessagingServiceAbstraction,
|
||||
],
|
||||
}),
|
||||
safeProvider({
|
||||
|
||||
@@ -1,18 +1,9 @@
|
||||
// FIXME: Update this file to be type safe and remove this and next line
|
||||
// @ts-strict-ignore
|
||||
import {
|
||||
combineLatest,
|
||||
distinctUntilChanged,
|
||||
filter,
|
||||
firstValueFrom,
|
||||
Observable,
|
||||
of,
|
||||
switchMap,
|
||||
} from "rxjs";
|
||||
import { combineLatest, filter, firstValueFrom, Observable, of, switchMap } from "rxjs";
|
||||
|
||||
import { LogoutReason } from "@bitwarden/auth/common";
|
||||
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
||||
import { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service";
|
||||
import {
|
||||
Argon2KdfConfig,
|
||||
KdfConfig,
|
||||
@@ -64,7 +55,6 @@ export class KeyConnectorService implements KeyConnectorServiceAbstraction {
|
||||
private keyGenerationService: KeyGenerationService,
|
||||
private logoutCallback: (logoutReason: LogoutReason, userId?: string) => Promise<void>,
|
||||
private stateProvider: StateProvider,
|
||||
private messagingService: MessagingService,
|
||||
) {
|
||||
this.convertAccountRequired$ = accountService.activeAccount$.pipe(
|
||||
filter((account) => account != null),
|
||||
@@ -80,18 +70,12 @@ export class KeyConnectorService implements KeyConnectorServiceAbstraction {
|
||||
tokenService.hasAccessToken$(account.id).pipe(filter((hasToken) => hasToken)),
|
||||
]),
|
||||
),
|
||||
distinctUntilChanged(),
|
||||
switchMap(async ([userId, organizations, usesKeyConnector]) => {
|
||||
const loggedInUsingSso = await this.tokenService.getIsExternal(userId);
|
||||
const requiredByOrganization = this.findManagingOrganization(organizations) != null;
|
||||
const userIsNotUsingKeyConnector = !usesKeyConnector;
|
||||
|
||||
const needsMigration =
|
||||
loggedInUsingSso && requiredByOrganization && userIsNotUsingKeyConnector;
|
||||
if (needsMigration) {
|
||||
this.messagingService.send("convertAccountToKeyConnector");
|
||||
}
|
||||
return needsMigration;
|
||||
return loggedInUsingSso && requiredByOrganization && userIsNotUsingKeyConnector;
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -214,6 +214,10 @@ export class DefaultSyncService extends CoreSyncService {
|
||||
await this.providerService.save(providers, response.id);
|
||||
|
||||
await this.syncProfileOrganizations(response, response.id);
|
||||
|
||||
if (await firstValueFrom(this.keyConnectorService.convertAccountRequired$)) {
|
||||
this.messageSender.send("convertAccountToKeyConnector");
|
||||
}
|
||||
}
|
||||
|
||||
private async setForceSetPasswordReasonIfNeeded(profileResponse: ProfileResponse) {
|
||||
|
||||
Reference in New Issue
Block a user