mirror of
https://github.com/bitwarden/browser
synced 2025-12-19 01:33:33 +00:00
[AC-1139] Moved overriding of deprecated values to syncService
This commit is contained in:
@@ -450,6 +450,7 @@ import { AbstractThemingService } from "./theming/theming.service.abstraction";
|
||||
FolderApiServiceAbstraction,
|
||||
OrganizationServiceAbstraction,
|
||||
SendApiServiceAbstraction,
|
||||
ConfigServiceAbstraction,
|
||||
LOGOUT_CALLBACK,
|
||||
],
|
||||
},
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
import { BehaviorSubject, concatMap, map, Observable } from "rxjs";
|
||||
|
||||
import { FeatureFlag } from "../../../enums/feature-flag.enum";
|
||||
import { ConfigServiceAbstraction } from "../../../platform/abstractions/config/config.service.abstraction";
|
||||
import { StateService } from "../../../platform/abstractions/state.service";
|
||||
import {
|
||||
InternalOrganizationServiceAbstraction,
|
||||
isMember,
|
||||
} from "../../abstractions/organization/organization.service.abstraction";
|
||||
import { OrganizationUserType } from "../../enums";
|
||||
import { OrganizationData } from "../../models/data/organization.data";
|
||||
import { Organization } from "../../models/domain/organization";
|
||||
|
||||
@@ -17,7 +14,7 @@ export class OrganizationService implements InternalOrganizationServiceAbstracti
|
||||
organizations$ = this._organizations.asObservable();
|
||||
memberOrganizations$ = this.organizations$.pipe(map((orgs) => orgs.filter(isMember)));
|
||||
|
||||
constructor(private stateService: StateService, private configService: ConfigServiceAbstraction) {
|
||||
constructor(private stateService: StateService) {
|
||||
this.stateService.activeAccountUnlocked$
|
||||
.pipe(
|
||||
concatMap(async (unlocked) => {
|
||||
@@ -106,20 +103,6 @@ export class OrganizationService implements InternalOrganizationServiceAbstracti
|
||||
}
|
||||
|
||||
async replace(organizations: { [id: string]: OrganizationData }) {
|
||||
// If Flexible Collections is enabled, treat Managers as Users and ignore deprecated permissions
|
||||
if (await this.configService.getFeatureFlag(FeatureFlag.FlexibleCollections)) {
|
||||
Object.values(organizations).forEach((o) => {
|
||||
if (o.type === OrganizationUserType.Manager) {
|
||||
o.type = OrganizationUserType.User;
|
||||
}
|
||||
|
||||
if (o.permissions != null) {
|
||||
o.permissions.editAssignedCollections = false;
|
||||
o.permissions.deleteAssignedCollections = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
await this.stateService.setOrganizations(organizations);
|
||||
this.updateObservables(organizations);
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import { ProviderData } from "../../../admin-console/models/data/provider.data";
|
||||
import { PolicyResponse } from "../../../admin-console/models/response/policy.response";
|
||||
import { KeyConnectorService } from "../../../auth/abstractions/key-connector.service";
|
||||
import { ForceSetPasswordReason } from "../../../auth/models/domain/force-set-password-reason";
|
||||
import { FeatureFlag } from "../../../enums/feature-flag.enum";
|
||||
import { DomainsResponse } from "../../../models/response/domains.response";
|
||||
import {
|
||||
SyncCipherNotification,
|
||||
@@ -17,6 +18,7 @@ import {
|
||||
SyncSendNotification,
|
||||
} from "../../../models/response/notification.response";
|
||||
import { ProfileResponse } from "../../../models/response/profile.response";
|
||||
import { ConfigServiceAbstraction } from "../../../platform/abstractions/config/config.service.abstraction";
|
||||
import { CryptoService } from "../../../platform/abstractions/crypto.service";
|
||||
import { LogService } from "../../../platform/abstractions/log.service";
|
||||
import { MessagingService } from "../../../platform/abstractions/messaging.service";
|
||||
@@ -59,6 +61,7 @@ export class SyncService implements SyncServiceAbstraction {
|
||||
private folderApiService: FolderApiServiceAbstraction,
|
||||
private organizationService: InternalOrganizationServiceAbstraction,
|
||||
private sendApiService: SendApiService,
|
||||
private configService: ConfigServiceAbstraction,
|
||||
private logoutCallback: (expired: boolean) => Promise<void>
|
||||
) {}
|
||||
|
||||
@@ -394,6 +397,20 @@ export class SyncService implements SyncServiceAbstraction {
|
||||
}
|
||||
});
|
||||
|
||||
// If Flexible Collections is enabled, treat Managers as Users and ignore deprecated permissions
|
||||
if (await this.configService.getFeatureFlag(FeatureFlag.FlexibleCollections)) {
|
||||
Object.values(organizations).forEach((o) => {
|
||||
if (o.type === OrganizationUserType.Manager) {
|
||||
o.type = OrganizationUserType.User;
|
||||
}
|
||||
|
||||
if (o.permissions != null) {
|
||||
o.permissions.editAssignedCollections = false;
|
||||
o.permissions.deleteAssignedCollections = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
await this.organizationService.replace(organizations);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user