-
Notifications
You must be signed in to change notification settings - Fork 0
Fix sign-in redirect stall #50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| <script lang="ts"> | ||
| import { base } from '$app/paths'; | ||
| import { onMount } from 'svelte'; | ||
|
|
||
| let { to }: { to: `/${string}` } = $props(); | ||
|
|
||
| onMount(() => { | ||
| window.location.replace(`${base}${to}`); | ||
| }); | ||
| </script> |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,14 +1,17 @@ | ||||||||||||||||||||||||||||
| <script lang="ts"> | ||||||||||||||||||||||||||||
| import { page } from '$app/state'; | ||||||||||||||||||||||||||||
| import AuthWidgetLoading from '$lib/components/auth-widget-loading.svelte'; | ||||||||||||||||||||||||||||
| import PostAuthRedirect from '$lib/components/post-auth-redirect.svelte'; | ||||||||||||||||||||||||||||
| import ClerkLoaded from 'clerk-sveltekit/client/ClerkLoaded.svelte'; | ||||||||||||||||||||||||||||
| import ClerkLoading from 'clerk-sveltekit/client/ClerkLoading.svelte'; | ||||||||||||||||||||||||||||
| import SignIn from 'clerk-sveltekit/client/SignIn.svelte'; | ||||||||||||||||||||||||||||
| import { safeRedirectPath } from '$lib/auth-redirect'; | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| const redirectUrl = $derived( | ||||||||||||||||||||||||||||
| safeRedirectPath( | ||||||||||||||||||||||||||||
| page.url.searchParams.get('redirect_url') ?? page.url.searchParams.get('redirectUrl') | ||||||||||||||||||||||||||||
| page.url.searchParams.get('redirect_url') ?? | ||||||||||||||||||||||||||||
| page.url.searchParams.get('redirectUrl') ?? | ||||||||||||||||||||||||||||
| page.url.searchParams.get('redirectAfterAuth') | ||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||
|
Comment on lines
8
to
16
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time! |
||||||||||||||||||||||||||||
| </script> | ||||||||||||||||||||||||||||
|
|
@@ -26,8 +29,13 @@ | |||||||||||||||||||||||||||
| <ClerkLoading> | ||||||||||||||||||||||||||||
| <AuthWidgetLoading /> | ||||||||||||||||||||||||||||
| </ClerkLoading> | ||||||||||||||||||||||||||||
| <ClerkLoaded> | ||||||||||||||||||||||||||||
| <SignIn {redirectUrl} signUpUrl="/sign-up" /> | ||||||||||||||||||||||||||||
| <ClerkLoaded let:clerk> | ||||||||||||||||||||||||||||
| {#if clerk?.user} | ||||||||||||||||||||||||||||
| <PostAuthRedirect to={redirectUrl} /> | ||||||||||||||||||||||||||||
| <AuthWidgetLoading /> | ||||||||||||||||||||||||||||
| {:else} | ||||||||||||||||||||||||||||
| <SignIn {redirectUrl} signUpUrl="/sign-up" /> | ||||||||||||||||||||||||||||
| {/if} | ||||||||||||||||||||||||||||
| </ClerkLoaded> | ||||||||||||||||||||||||||||
| </section> | ||||||||||||||||||||||||||||
| </main> | ||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
??chain order was accidentally reversed soredirectAfterAuthbeatredirect_url, no existing test would catch it. Adding a case where multiple params are present (e.g.,redirect_url=/runs&redirectAfterAuth=/other) and asserting the expected winner would fully verify the precedence contract.