From 249c7324a2c3aed53e777db999549b3d2cd371df Mon Sep 17 00:00:00 2001 From: Thibault Le Ouay Date: Thu, 17 Oct 2024 22:40:30 +0200 Subject: [PATCH] Improve error message for Graphql API (#7805) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ![CleanShot 2024-10-17 at 11 39 39](https://github.com/user-attachments/assets/616b8317-de1f-4b61-b2b4-980b14b09f66) This improves this error message. --------- Co-authored-by: Félix Malfait --- .../src/engine/decorators/auth/auth-user.decorator.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/twenty-server/src/engine/decorators/auth/auth-user.decorator.ts b/packages/twenty-server/src/engine/decorators/auth/auth-user.decorator.ts index 75f3a982e..35d3ccc08 100644 --- a/packages/twenty-server/src/engine/decorators/auth/auth-user.decorator.ts +++ b/packages/twenty-server/src/engine/decorators/auth/auth-user.decorator.ts @@ -15,7 +15,9 @@ export const AuthUser = createParamDecorator( const request = getRequest(ctx); if (!options?.allowUndefined && !request.user) { - throw new ForbiddenException("You're not authorized to do this"); + throw new ForbiddenException( + "You're not authorized to do this. Note: This endpoint requires a user and won't work with just an API key.", + ); } return request.user;