From 19f7d8acd10e659df5822eb6566d2b270285b31b Mon Sep 17 00:00:00 2001 From: andrewwallacespeckle Date: Fri, 30 May 2025 13:27:55 +0200 Subject: [PATCH] fix(fe): fix signup error parsing to display server messages --- .../components/auth/RegisterWithEmailBlock.vue | 2 +- packages/frontend-2/lib/auth/services/auth.ts | 16 +++++++++++++++- .../lib/common/generated/gql/graphql.ts | 4 ++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/packages/frontend-2/components/auth/RegisterWithEmailBlock.vue b/packages/frontend-2/components/auth/RegisterWithEmailBlock.vue index 1bd3e5f52..6ad390fea 100644 --- a/packages/frontend-2/components/auth/RegisterWithEmailBlock.vue +++ b/packages/frontend-2/components/auth/RegisterWithEmailBlock.vue @@ -13,6 +13,7 @@ :rules="emailRules" show-label :disabled="isEmailDisabled" + auto-focus :help=" emailIsBlocked ? 'A work email makes it easier to discover and collaborate with your coworkers on Speckle.' @@ -31,7 +32,6 @@ color="foundation" show-label :disabled="loading" - auto-focus autocomplete="name" /> { if (!res.redirected) { // for some reason the error response structure differs between /login and /register... - const body = (await res.json()) as { err?: boolean | string; message?: string } + const body = (await res.json()) as { + err?: boolean | string + message?: string + error?: { message: string } + } if (body.err) { const errMsg = isString(body.err) ? body.err @@ -46,6 +50,16 @@ async function resolveAccessCode(res: Response): Promise { throw new AuthFailedError(errMsg) } + // Check for error.message structure + if (body.error?.message) { + throw new AuthFailedError(body.error.message) + } + + // Check for direct message + if (body.message) { + throw new AuthFailedError(body.message) + } + throw new AuthFailedError('Authentication request unexpectedly did not redirect') } diff --git a/packages/frontend-2/lib/common/generated/gql/graphql.ts b/packages/frontend-2/lib/common/generated/gql/graphql.ts index 70748eeaf..99d0307e3 100644 --- a/packages/frontend-2/lib/common/generated/gql/graphql.ts +++ b/packages/frontend-2/lib/common/generated/gql/graphql.ts @@ -4589,6 +4589,7 @@ export type WorkspaceBillingMutationsUpgradePlanArgs = { /** Overridden by `WorkspaceCollaboratorGraphQLReturn` */ export type WorkspaceCollaborator = { __typename?: 'WorkspaceCollaborator'; + email?: Maybe; id: Scalars['ID']['output']; /** Date that the user joined the workspace. */ joinDate: Scalars['DateTime']['output']; @@ -4733,6 +4734,7 @@ export type WorkspaceInviteUseInput = { export type WorkspaceJoinRequest = { __typename?: 'WorkspaceJoinRequest'; createdAt: Scalars['DateTime']['output']; + email?: Maybe; id: Scalars['String']['output']; status: WorkspaceJoinRequestStatus; user: LimitedUser; @@ -9110,6 +9112,7 @@ export type WorkspaceBillingMutationsFieldArgs = { upgradePlan: WorkspaceBillingMutationsUpgradePlanArgs, } export type WorkspaceCollaboratorFieldArgs = { + email: {}, id: {}, joinDate: {}, projectRoles: {}, @@ -9147,6 +9150,7 @@ export type WorkspaceInviteMutationsFieldArgs = { } export type WorkspaceJoinRequestFieldArgs = { createdAt: {}, + email: {}, id: {}, status: {}, user: {},