feat(workspace): expand forbidden subdomain validation (#9082)
Added new forbidden words and regex patterns to subdomain validation in `update-workspace-input`. Enhanced the `ForbiddenWords` validator to support both strings and regex matching. Updated tests to verify regex-based forbidden subdomain validation. Fix #9064 --------- Co-authored-by: Weiko <corentin@twenty.com>
This commit is contained in:
@ -1,39 +0,0 @@
|
||||
import {
|
||||
ArgumentsHost,
|
||||
Catch,
|
||||
ExceptionFilter,
|
||||
HttpException,
|
||||
} from '@nestjs/common';
|
||||
|
||||
import { Response } from 'express';
|
||||
|
||||
// In case of exception in middleware run before the CORS middleware (eg: JSON Middleware that checks the request body),
|
||||
// the CORS headers are missing in the response.
|
||||
// This class add CORS headers to exception response to avoid misleading CORS error
|
||||
@Catch()
|
||||
export class UnhandledExceptionFilter implements ExceptionFilter {
|
||||
catch(exception: any, host: ArgumentsHost) {
|
||||
const ctx = host.switchToHttp();
|
||||
const response = ctx.getResponse<Response>();
|
||||
|
||||
if (!response.header) {
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: Check if needed, remove otherwise.
|
||||
response.header('Access-Control-Allow-Origin', '*');
|
||||
response.header(
|
||||
'Access-Control-Allow-Methods',
|
||||
'GET,HEAD,PUT,PATCH,POST,DELETE',
|
||||
);
|
||||
response.header(
|
||||
'Access-Control-Allow-Headers',
|
||||
'Origin, X-Requested-With, Content-Type, Accept',
|
||||
);
|
||||
|
||||
const status =
|
||||
exception instanceof HttpException ? exception.getStatus() : 500;
|
||||
|
||||
response.status(status).json(exception.response);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user