fix(fe): fix signup error parsing to display server messages

fix(fe): fix signup error parsing to display server messages
This commit is contained in:
andrewwallacespeckle
2025-05-30 13:44:10 +02:00
committed by GitHub
3 changed files with 20 additions and 2 deletions
@@ -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"
/>
<FormTextInput
+15 -1
View File
@@ -38,7 +38,11 @@ type RegisterParams = {
async function resolveAccessCode(res: Response): Promise<string> {
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<string> {
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')
}
@@ -4589,6 +4589,7 @@ export type WorkspaceBillingMutationsUpgradePlanArgs = {
/** Overridden by `WorkspaceCollaboratorGraphQLReturn` */
export type WorkspaceCollaborator = {
__typename?: 'WorkspaceCollaborator';
email?: Maybe<Scalars['String']['output']>;
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<Scalars['String']['output']>;
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: {},