From be18ee4d7d4e0056429b573d2564be76b3496553 Mon Sep 17 00:00:00 2001 From: martmull Date: Fri, 14 Jun 2024 12:41:55 +0200 Subject: [PATCH] Fix sentry error (#5848) Fixes https://twenty-v7.sentry.io/issues/5363536663/?environment=prod&project=4507072499810304&query=is%3Aunresolved+issue.priority%3A%5Bhigh%2C+medium%5D&referrer=issue-stream&statsPeriod=7d&stream_index=0 - handle error properly in twenty-server - display backend error message --- .../auth/sign-in-up/hooks/useWorkspaceFromInviteHash.ts | 4 ++-- .../src/engine/core-modules/auth/auth.resolver.ts | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/twenty-front/src/modules/auth/sign-in-up/hooks/useWorkspaceFromInviteHash.ts b/packages/twenty-front/src/modules/auth/sign-in-up/hooks/useWorkspaceFromInviteHash.ts index ee6234feb..feee086ef 100644 --- a/packages/twenty-front/src/modules/auth/sign-in-up/hooks/useWorkspaceFromInviteHash.ts +++ b/packages/twenty-front/src/modules/auth/sign-in-up/hooks/useWorkspaceFromInviteHash.ts @@ -22,8 +22,8 @@ export const useWorkspaceFromInviteHash = () => { const { data: workspaceFromInviteHash, loading } = useGetWorkspaceFromInviteHashQuery({ variables: { inviteHash: workspaceInviteHash || '' }, - onError: () => { - enqueueSnackBar('workspace does not exist', { + onError: (error) => { + enqueueSnackBar(error.message, { variant: SnackBarVariant.Error, }); navigate(AppPath.Index); diff --git a/packages/twenty-server/src/engine/core-modules/auth/auth.resolver.ts b/packages/twenty-server/src/engine/core-modules/auth/auth.resolver.ts index 9ce29e324..2c6466eee 100644 --- a/packages/twenty-server/src/engine/core-modules/auth/auth.resolver.ts +++ b/packages/twenty-server/src/engine/core-modules/auth/auth.resolver.ts @@ -82,9 +82,15 @@ export class AuthResolver { async findWorkspaceFromInviteHash( @Args() workspaceInviteHashValidInput: WorkspaceInviteHashValidInput, ) { - return await this.workspaceRepository.findOneBy({ + const workspace = await this.workspaceRepository.findOneBy({ inviteHash: workspaceInviteHashValidInput.inviteHash, }); + + if (!workspace) { + throw new BadRequestException('Workspace does not exist'); + } + + return workspace; } @UseGuards(CaptchaGuard)