Skip to content

Conversation

@weebao
Copy link
Member

@weebao weebao commented Aug 24, 2025

Fixes infinite loading when username already exists during Google OAuth registration by properly handling form state and error messages.

₍ᐢ•(ܫ)•ᐢ₎ Generated by Scout (view jam)

- Scout jam: [74c93e4f-3ac1-4a42-917c-e211ec198b0c](https://scout.new/jam/74c93e4f-3ac1-4a42-917c-e211ec198b0c)

Co-authored-by: Scout <scout@scout.new>
@weebao weebao added the scout PR created by Scout label Aug 24, 2025
Copilot AI review requested due to automatic review settings August 24, 2025 20:05
@weebao weebao added the scout PR created by Scout label Aug 24, 2025
- Scout jam: [74c93e4f-3ac1-4a42-917c-e211ec198b0c](https://scout.new/jam/74c93e4f-3ac1-4a42-917c-e211ec198b0c)

Co-authored-by: Scout <scout@scout.new>
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Fixes infinite loading bug when username already exists during Google OAuth registration by updating form state management and improving error handling.

  • Refactored superForm state management to properly extract and use form utilities
  • Added field-specific error handling for username and email validation errors
  • Updated error response structure to use consistent "message" property

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
src/routes/(auth)/login/google/callback/+page.svelte Refactored form state management to extract superForm utilities and updated form binding patterns
src/routes/(auth)/login/google/callback/+page.server.ts Added field-specific error handling and standardized error response format
docs/changes.md Added changelog entry documenting the bug fix

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines 113 to 117
<input type="hidden" name="google_id" bind:value={$formData.google_id} />
<input
type="hidden"
name="avatar_url"
value={registerFormData.avatar_url}
bind:value={$formData.avatar_url}
Copy link

Copilot AI Aug 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hidden inputs should use value attribute instead of bind:value since they don't need two-way data binding and the values are already managed by the form state.

Copilot uses AI. Check for mistakes.
Comment on lines +50 to +58
if (response.status === 400) {
const message: string = response.error.detail;
if (message.toLowerCase().includes("username")) {
form.errors.username = [message];
} else if (message.toLowerCase().includes("email")) {
form.errors.email = [message];
}
return fail(400, { form, message });
}
Copy link

Copilot AI Aug 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message parsing using toLowerCase().includes() is fragile and could fail if the error message format changes. Consider using more specific error codes or structured error responses from the registerWithGoogle function instead of string matching.

Copilot uses AI. Check for mistakes.
@weebao weebao changed the title Fix Google OAuth infinite loading bug fix: Google OAuth infinite loading bug Aug 24, 2025
weebao and others added 3 commits August 24, 2025 20:16
- Scout jam: [74c93e4f-3ac1-4a42-917c-e211ec198b0c](https://scout.new/jam/74c93e4f-3ac1-4a42-917c-e211ec198b0c)

Co-authored-by: Scout <scout@scout.new>
- Scout jam: [74c93e4f-3ac1-4a42-917c-e211ec198b0c](https://scout.new/jam/74c93e4f-3ac1-4a42-917c-e211ec198b0c)

Co-authored-by: Scout <scout@scout.new>
@weebao weebao merged commit 43c5810 into main Aug 25, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scout PR created by Scout

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants