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:
@ -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;
|
||||
|
||||
Reference in New Issue
Block a user