mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-21 11:35:34 +01:00
[AC-1893] Removed logic to downgrade Manager roles and remove Edit/Delete any collection permissions for Flexible Collections (#7365)
This commit is contained in:
parent
0874df8b84
commit
48643e45ea
@ -581,7 +581,6 @@ export default class MainBackground {
|
||||
this.folderApiService,
|
||||
this.organizationService,
|
||||
this.sendApiService,
|
||||
this.configService,
|
||||
logoutCallback,
|
||||
);
|
||||
this.eventUploadService = new EventUploadService(
|
||||
|
@ -480,7 +480,6 @@ export class Main {
|
||||
this.folderApiService,
|
||||
this.organizationService,
|
||||
this.sendApiService,
|
||||
this.configService,
|
||||
async (expired: boolean) => await this.logout(),
|
||||
);
|
||||
|
||||
|
@ -9,8 +9,6 @@ import { Organization } from "@bitwarden/common/admin-console/models/domain/orga
|
||||
import { SecretsManagerSubscribeRequest } from "@bitwarden/common/billing/models/request/sm-subscribe.request";
|
||||
import { BillingCustomerDiscount } from "@bitwarden/common/billing/models/response/organization-subscription.response";
|
||||
import { PlanResponse } from "@bitwarden/common/billing/models/response/plan.response";
|
||||
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";
|
||||
import { ConfigServiceAbstraction } from "@bitwarden/common/platform/abstractions/config/config.service.abstraction";
|
||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
||||
|
||||
@ -35,7 +33,6 @@ export class SecretsManagerSubscribeStandaloneComponent {
|
||||
private i18nService: I18nService,
|
||||
private organizationApiService: OrganizationApiServiceAbstraction,
|
||||
private organizationService: InternalOrganizationServiceAbstraction,
|
||||
private configService: ConfigServiceAbstraction,
|
||||
) {}
|
||||
|
||||
submit = async () => {
|
||||
@ -55,11 +52,7 @@ export class SecretsManagerSubscribeStandaloneComponent {
|
||||
isMember: this.organization.isMember,
|
||||
isProviderUser: this.organization.isProviderUser,
|
||||
});
|
||||
const flexibleCollectionsEnabled = await this.configService.getFeatureFlag(
|
||||
FeatureFlag.FlexibleCollections,
|
||||
false,
|
||||
);
|
||||
await this.organizationService.upsert(organizationData, flexibleCollectionsEnabled);
|
||||
await this.organizationService.upsert(organizationData);
|
||||
|
||||
/*
|
||||
Because subscribing to Secrets Manager automatically provides access to Secrets Manager for the
|
||||
|
@ -461,7 +461,6 @@ import { ModalService } from "./modal.service";
|
||||
FolderApiServiceAbstraction,
|
||||
OrganizationServiceAbstraction,
|
||||
SendApiServiceAbstraction,
|
||||
ConfigServiceAbstraction,
|
||||
LOGOUT_CALLBACK,
|
||||
],
|
||||
},
|
||||
|
@ -95,12 +95,6 @@ export abstract class OrganizationService {
|
||||
}
|
||||
|
||||
export abstract class InternalOrganizationServiceAbstraction extends OrganizationService {
|
||||
replace: (
|
||||
organizations: { [id: string]: OrganizationData },
|
||||
flexibleCollectionsEnabled: boolean,
|
||||
) => Promise<void>;
|
||||
upsert: (
|
||||
OrganizationData: OrganizationData | OrganizationData[],
|
||||
flexibleCollectionsEnabled: boolean,
|
||||
) => Promise<void>;
|
||||
replace: (organizations: { [id: string]: OrganizationData }) => Promise<void>;
|
||||
upsert: (OrganizationData: OrganizationData | OrganizationData[]) => Promise<void>;
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ describe("Organization Service", () => {
|
||||
});
|
||||
|
||||
it("upsert", async () => {
|
||||
await organizationService.upsert(organizationData("2", "Test 2"), false);
|
||||
await organizationService.upsert(organizationData("2", "Test 2"));
|
||||
|
||||
expect(await firstValueFrom(organizationService.organizations$)).toEqual([
|
||||
{
|
||||
@ -146,7 +146,7 @@ describe("Organization Service", () => {
|
||||
|
||||
describe("delete", () => {
|
||||
it("exists", async () => {
|
||||
await organizationService.delete("1", false);
|
||||
await organizationService.delete("1");
|
||||
|
||||
expect(stateService.getOrganizations).toHaveBeenCalledTimes(2);
|
||||
|
||||
@ -154,7 +154,7 @@ describe("Organization Service", () => {
|
||||
});
|
||||
|
||||
it("does not exist", async () => {
|
||||
organizationService.delete("1", false);
|
||||
organizationService.delete("1");
|
||||
|
||||
expect(stateService.getOrganizations).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
|
@ -5,7 +5,6 @@ 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";
|
||||
|
||||
@ -52,7 +51,7 @@ export class OrganizationService implements InternalOrganizationServiceAbstracti
|
||||
return organizations.length > 0;
|
||||
}
|
||||
|
||||
async upsert(organization: OrganizationData, flexibleCollectionsEnabled: boolean): Promise<void> {
|
||||
async upsert(organization: OrganizationData): Promise<void> {
|
||||
let organizations = await this.stateService.getOrganizations();
|
||||
if (organizations == null) {
|
||||
organizations = {};
|
||||
@ -60,10 +59,10 @@ export class OrganizationService implements InternalOrganizationServiceAbstracti
|
||||
|
||||
organizations[organization.id] = organization;
|
||||
|
||||
await this.replace(organizations, flexibleCollectionsEnabled);
|
||||
await this.replace(organizations);
|
||||
}
|
||||
|
||||
async delete(id: string, flexibleCollectionsEnabled: boolean): Promise<void> {
|
||||
async delete(id: string): Promise<void> {
|
||||
const organizations = await this.stateService.getOrganizations();
|
||||
if (organizations == null) {
|
||||
return;
|
||||
@ -74,7 +73,7 @@ export class OrganizationService implements InternalOrganizationServiceAbstracti
|
||||
}
|
||||
|
||||
delete organizations[id];
|
||||
await this.replace(organizations, flexibleCollectionsEnabled);
|
||||
await this.replace(organizations);
|
||||
}
|
||||
|
||||
get(id: string): Organization {
|
||||
@ -103,24 +102,7 @@ export class OrganizationService implements InternalOrganizationServiceAbstracti
|
||||
return organizations.find((organization) => organization.identifier === identifier);
|
||||
}
|
||||
|
||||
async replace(
|
||||
organizations: { [id: string]: OrganizationData },
|
||||
flexibleCollectionsEnabled: boolean,
|
||||
) {
|
||||
// If Flexible Collections is enabled, treat Managers as Users and ignore deprecated permissions
|
||||
if (flexibleCollectionsEnabled) {
|
||||
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;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async replace(organizations: { [id: string]: OrganizationData }) {
|
||||
await this.stateService.setOrganizations(organizations);
|
||||
this.updateObservables(organizations);
|
||||
}
|
||||
|
@ -10,7 +10,6 @@ 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,
|
||||
@ -18,7 +17,6 @@ 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";
|
||||
@ -61,7 +59,6 @@ export class SyncService implements SyncServiceAbstraction {
|
||||
private folderApiService: FolderApiServiceAbstraction,
|
||||
private organizationService: InternalOrganizationServiceAbstraction,
|
||||
private sendApiService: SendApiService,
|
||||
private configService: ConfigServiceAbstraction,
|
||||
private logoutCallback: (expired: boolean) => Promise<void>,
|
||||
) {}
|
||||
|
||||
@ -321,11 +318,7 @@ export class SyncService implements SyncServiceAbstraction {
|
||||
|
||||
await this.setForceSetPasswordReasonIfNeeded(response);
|
||||
|
||||
const flexibleCollectionsEnabled = await this.configService.getFeatureFlag(
|
||||
FeatureFlag.FlexibleCollections,
|
||||
false,
|
||||
);
|
||||
await this.syncProfileOrganizations(response, flexibleCollectionsEnabled);
|
||||
await this.syncProfileOrganizations(response);
|
||||
|
||||
const providers: { [id: string]: ProviderData } = {};
|
||||
response.providers.forEach((p) => {
|
||||
@ -393,10 +386,7 @@ export class SyncService implements SyncServiceAbstraction {
|
||||
}
|
||||
}
|
||||
|
||||
private async syncProfileOrganizations(
|
||||
response: ProfileResponse,
|
||||
flexibleCollectionsEnabled: boolean,
|
||||
) {
|
||||
private async syncProfileOrganizations(response: ProfileResponse) {
|
||||
const organizations: { [id: string]: OrganizationData } = {};
|
||||
response.organizations.forEach((o) => {
|
||||
organizations[o.id] = new OrganizationData(o, {
|
||||
@ -416,7 +406,7 @@ export class SyncService implements SyncServiceAbstraction {
|
||||
}
|
||||
});
|
||||
|
||||
await this.organizationService.replace(organizations, flexibleCollectionsEnabled);
|
||||
await this.organizationService.replace(organizations);
|
||||
}
|
||||
|
||||
private async syncFolders(response: FolderResponse[]) {
|
||||
|
Loading…
Reference in New Issue
Block a user