Fix RLS entitlement check + fix role page with RLS on object without object-permission not being displayed (#17326)

This commit is contained in:
Weiko
2026-01-22 11:48:24 +01:00
committed by GitHub
parent f10515fc2d
commit 670ff1583e
7 changed files with 48 additions and 26 deletions
@@ -23,11 +23,12 @@ import {
BillingException,
BillingExceptionCode,
} from 'src/engine/core-modules/billing/billing.exception';
import { BillingEntitlementDTO } from 'src/engine/core-modules/billing/dtos/billing-entitlement.dto';
import { BillingCustomerEntity } from 'src/engine/core-modules/billing/entities/billing-customer.entity';
import { BillingEntitlementEntity } from 'src/engine/core-modules/billing/entities/billing-entitlement.entity';
import { BillingSubscriptionItemEntity } from 'src/engine/core-modules/billing/entities/billing-subscription-item.entity';
import { BillingSubscriptionEntity } from 'src/engine/core-modules/billing/entities/billing-subscription.entity';
import { type BillingEntitlementKey } from 'src/engine/core-modules/billing/enums/billing-entitlement-key.enum';
import { BillingEntitlementKey } from 'src/engine/core-modules/billing/enums/billing-entitlement-key.enum';
import { BillingProductKey } from 'src/engine/core-modules/billing/enums/billing-product-key.enum';
import { SubscriptionStatus } from 'src/engine/core-modules/billing/enums/billing-subscription-status.enum';
import { BillingPlanService } from 'src/engine/core-modules/billing/services/billing-plan.service';
@@ -177,18 +178,31 @@ export class BillingSubscriptionService {
async getWorkspaceEntitlements(
workspaceId: string,
): Promise<BillingEntitlementEntity[]> {
): Promise<BillingEntitlementDTO[]> {
const isBillingEnabled = this.twentyConfigService.get('IS_BILLING_ENABLED');
if (!isBillingEnabled) {
return [];
}
const hasValidEnterpriseKey = isDefined(
this.twentyConfigService.get('ENTERPRISE_KEY'),
);
const entitlements = await this.billingEntitlementRepository.find({
where: { workspaceId },
});
return entitlements;
const entitlementsByKey = entitlements.reduce(
(acc, entitlement) => {
acc[entitlement.key] = entitlement;
return acc;
},
{} as Record<BillingEntitlementKey, BillingEntitlementEntity>,
);
return Object.values(BillingEntitlementKey).map((key) => ({
key,
value:
hasValidEnterpriseKey &&
(!isBillingEnabled || (entitlementsByKey[key]?.value ?? false)),
}));
}
async getWorkspaceEntitlementByKey(
@@ -18,8 +18,8 @@ import assert from 'assert';
import GraphQLUpload from 'graphql-upload/GraphQLUpload.mjs';
import { PermissionFlagType } from 'twenty-shared/constants';
import { assertIsDefinedOrThrow, isDefined } from 'twenty-shared/utils';
import { FileFolder } from 'twenty-shared/types';
import { assertIsDefinedOrThrow, isDefined } from 'twenty-shared/utils';
import type { FileUpload } from 'graphql-upload/processRequest.mjs';