@ -1,3 +1,5 @@
|
||||
import { FeatureFlagKey } from 'src/engine/core-modules/feature-flag/enums/feature-flag-key.enum';
|
||||
import { isPublicFeatureFlag } from 'src/engine/core-modules/lab/utils/is-public-feature-flag.util';
|
||||
import { TypedReflect } from 'src/utils/typed-reflect';
|
||||
|
||||
export interface WorkspaceGateOptions {
|
||||
@ -5,6 +7,15 @@ export interface WorkspaceGateOptions {
|
||||
}
|
||||
|
||||
export function WorkspaceGate(options: WorkspaceGateOptions) {
|
||||
const flagKey = options.featureFlag as FeatureFlagKey;
|
||||
|
||||
if (isPublicFeatureFlag(flagKey)) {
|
||||
throw new Error(
|
||||
`Public feature flag "${flagKey}" cannot be used to gate entities. ` +
|
||||
'Public flags should not be used for entity gating as they can be toggled by users.',
|
||||
);
|
||||
}
|
||||
|
||||
return (target: any, propertyKey?: string | symbol) => {
|
||||
if (propertyKey !== undefined) {
|
||||
TypedReflect.defineMetadata(
|
||||
|
||||
Reference in New Issue
Block a user