Skip to content

Commit

Permalink
Make RegisterResponse error properties optional
Browse files Browse the repository at this point in the history
  • Loading branch information
rmunn committed May 22, 2024
1 parent 024113c commit e563e4a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions frontend/src/lib/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export async function login(userId: string, password: string): Promise<LoginResu
: { success: false, error: await response.text() as LoginError };
}

export type RegisterResponse = { error?: { turnstile: boolean, accountExists: boolean, invalidInput: boolean }, user?: LexAuthUser };
export type RegisterResponse = { error?: { turnstile?: boolean, accountExists?: boolean, invalidInput?: boolean }, user?: LexAuthUser };
export async function createUser(endpoint: string, password: string, passwordStrength: number, name: string, email: string, locale: string, turnstileToken: string): Promise<RegisterResponse> {
const response = await fetch(endpoint, {
method: 'post',
Expand Down Expand Up @@ -133,13 +133,13 @@ export async function createGuestUserByAdmin(password: string, passwordStrength:
}
const gqlResponse = await _createGuestUserByAdmin(gqlInput);
if (gqlResponse.error?.byType('UniqueValueError')) {
return { error: { invalidInput: false, turnstile: false, accountExists: true }};
return { error: { accountExists: true }};
}
if (gqlResponse.error?.byType('RequiredError')) {
return { error: { invalidInput: true, turnstile: false, accountExists: false }};
return { error: { invalidInput: true }};
}
if (!gqlResponse.data?.createGuestUserByAdmin.lexAuthUser ) {
return { error: { invalidInput: true, turnstile: false, accountExists: false }};
return { error: { invalidInput: true }};
}
const responseUser = gqlResponse.data?.createGuestUserByAdmin.lexAuthUser;
const user: LexAuthUser = {
Expand Down

0 comments on commit e563e4a

Please sign in to comment.