Skip to content

The open alternative to Salesforce, designed for AI.

Fix sentry error (#5848)

martmullbe18ee4d7d4e
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 ee6234feb34..feee086ef7c 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 9ce29e324c0..2c6466eeea3 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)