mirror of
https://github.com/bitwarden/browser
synced 2025-12-15 07:43:35 +00: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:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user