Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 18 additions & 7 deletions src/routes/(public)/(guest)/login/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,18 @@
<svelte:fragment>
<Form onSubmit={login}>
<Layout.Stack>
{#if isCloud}
<Button
class="auth-provider-button"
secondary
fullWidth
on:click={onGithubLogin}
{disabled}>
<span class="icon-github" aria-hidden="true"></span>
<span class="text">Sign in with GitHub</span>
</Button>
<span class="with-separators eyebrow-heading-3">or</span>
{/if}
<InputEmail
id="email"
label="Email"
Expand All @@ -108,13 +120,6 @@
required={true}
bind:value={pass} />
<Button fullWidth submit {disabled}>Sign in</Button>
{#if isCloud}
<span class="with-separators eyebrow-heading-3">or</span>
<Button secondary fullWidth on:click={onGithubLogin} {disabled}>
<span class="icon-github" aria-hidden="true"></span>
<span class="text">Sign in with GitHub</span>
</Button>
{/if}
</Layout.Stack>
</Form>
</svelte:fragment>
Expand All @@ -129,3 +134,9 @@
</li>
</svelte:fragment>
</Unauthenticated>

<style>
:global(.auth-provider-button) {
margin-bottom: var(--gap-s, 8px);
}
</style>
31 changes: 19 additions & 12 deletions src/routes/(public)/(guest)/register/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,19 @@
<svelte:fragment>
<Form onSubmit={register}>
<Layout.Stack>
{#if isCloud}
<Button
class="auth-provider-button"
secondary
fullWidth
on:click={onGithubLogin}
disabled={disabled || !terms}>
<span class="icon-github" aria-hidden="true"></span>
<span class="text">Sign up with GitHub</span>
</Button>
<span class="with-separators eyebrow-heading-3">or</span>
{/if}
Comment on lines +127 to +138
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

Verify that campaign and coupon data is preserved for GitHub OAuth sign-ups.

The GitHub OAuth flow redirects to window.location.origin without preserving the coupon or campaign data present in data?.couponData or data?.campaign. Regular email registration handles this after account creation (lines 74-79), but GitHub OAuth users coming through campaign links may not receive the intended credits.

Run the following script to check if the OAuth callback handler preserves this context:


🏁 Script executed:

#!/bin/bash
# Description: Search for OAuth callback handling and campaign/coupon preservation logic

# Look for OAuth callback routes or handlers
rg -n -C5 'createOAuth2Session|oauth.*callback|oauth.*success' --type=ts --type=svelte

# Check if campaign/coupon data is preserved in OAuth flows
rg -n -C5 'couponData|campaign.*\$id' --type=ts --type=svelte -g '!register'

Length of output: 61


🏁 Script executed:

#!/bin/bash
# Description: Search for OAuth callback handling and campaign/coupon preservation logic

# Look for OAuth callback routes or handlers (broader search)
rg -n -C5 'createOAuth2Session|oauth.*callback|oauth.*success' --type=ts

# Search in all files for OAuth patterns
rg -n 'onGithubLogin|github.*oauth' -C3

# Check for coupon and campaign data references
rg -n 'couponData|campaign.*id' -C3

# Look for the registration file structure
fd -e svelte 'register' | head -20

Length of output: 46183


Preserve campaign and coupon context for GitHub OAuth sign-ups.

The GitHub OAuth flow redirects to window.location.origin without preserving coupon or campaign URL parameters. Users arriving via campaign links (e.g., /register?code=PROMO) will lose this context after OAuth completion, unlike email registration which correctly redirects to /apply-credit?code=....

Update the onGithubLogin function to preserve the code or campaign search parameters in the OAuth success URL:

function onGithubLogin() {
    let url = window.location.origin;
    
    if (page.url.searchParams.has('code')) {
        url += `?code=${page.url.searchParams.get('code')}`;
    } else if (page.url.searchParams.has('campaign')) {
        url += `?campaign=${page.url.searchParams.get('campaign')}`;
    }
    
    sdk.forConsole.account.createOAuth2Session({
        provider: OAuthProvider.Github,
        success: url,
        // ...
    });
}

Additionally, consider setting disabled = true after onGithubLogin() is called to prevent rapid re-clicks.

🤖 Prompt for AI Agents
In src/routes/(public)/(guest)/register/+page.svelte around lines 127 to 138,
the GitHub OAuth flow currently redirects to window.location.origin and loses
campaign/coupon query params; update onGithubLogin to read page.url.searchParams
and append either the code or campaign param (prefer code first, then campaign)
to the success URL passed to sdk.forConsole.account.createOAuth2Session so the
user returns with their promo context preserved, and after invoking the OAuth
call set disabled = true to prevent rapid re-clicks.


<InputText
id="name"
label="Name"
Expand Down Expand Up @@ -159,18 +172,6 @@
>.</InputChoice>

<Button fullWidth submit disabled={disabled || !terms}>Sign up</Button>

{#if isCloud}
<span class="with-separators eyebrow-heading-3">or</span>
<Button
secondary
fullWidth
on:click={onGithubLogin}
disabled={disabled || !terms}>
<span class="icon-github" aria-hidden="true"></span>
<span class="text">Sign up with GitHub</span>
</Button>
{/if}
</Layout.Stack>
</Form>
</svelte:fragment>
Expand All @@ -181,3 +182,9 @@
</Typography.Text>
</svelte:fragment>
</Unauthenticated>

<style>
:global(.auth-provider-button) {
margin-bottom: var(--gap-s, 8px);
}
</style>