Fix missing name validation on object names at update (#5434)

## Context
as per title

## How was it tested? 
local (/metadata + in product)
This commit is contained in:
Marie
2024-05-16 18:15:56 +02:00
committed by GitHub
parent d741f4a5bd
commit 1694e0cccd
4 changed files with 120 additions and 45 deletions

View File

@ -1,8 +1,4 @@
import {
ForbiddenException,
Injectable,
UnauthorizedException,
} from '@nestjs/common';
import { Injectable, UnauthorizedException } from '@nestjs/common';
import {
BeforeCreateOneHook,
@ -11,27 +7,6 @@ import {
import { CreateObjectInput } from 'src/engine/metadata-modules/object-metadata/dtos/create-object.input';
const coreObjectNames = [
'appToken',
'billingSubscription',
'billingSubscriptionItem',
'featureFlag',
'user',
'userWorkspace',
'workspace',
];
const reservedKeywords = [
...coreObjectNames,
'event',
'field',
'link',
'currency',
'fullName',
'address',
'links',
];
@Injectable()
export class BeforeCreateOneObject<T extends CreateObjectInput>
implements BeforeCreateOneHook<T, any>
@ -46,14 +21,6 @@ export class BeforeCreateOneObject<T extends CreateObjectInput>
throw new UnauthorizedException();
}
if (
reservedKeywords.includes(instance.input.nameSingular) ||
reservedKeywords.includes(instance.input.namePlural)
) {
throw new ForbiddenException(
'You cannot create an object with this name.',
);
}
instance.input.workspaceId = workspaceId;
return instance;