-
Notifications
You must be signed in to change notification settings - Fork 0
improve signup experience #37
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 | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -4,7 +4,10 @@ import { z } from 'zod'; | |||||||||||||
| import { useInvalidateMe } from '@/contexts/AuthContext'; | ||||||||||||||
| import { authClient } from '@/lib/auth/client'; | ||||||||||||||
|
|
||||||||||||||
| export function useRegisterForm(onSuccess: (email: string) => void) { | ||||||||||||||
| export function useRegisterForm( | ||||||||||||||
| onSuccess: (email: string) => void, | ||||||||||||||
| verificationCallbackUrl?: string, | ||||||||||||||
| ) { | ||||||||||||||
| const invalidateMe = useInvalidateMe(); | ||||||||||||||
| const [error, setError] = useState<string | null>(null); | ||||||||||||||
|
|
||||||||||||||
|
|
@@ -16,7 +19,9 @@ export function useRegisterForm(onSuccess: (email: string) => void) { | |||||||||||||
| name: value.name, | ||||||||||||||
| email: value.email, | ||||||||||||||
| password: value.password, | ||||||||||||||
| callbackURL: `${window.location.origin}/auth/verify-email`, | ||||||||||||||
| callbackURL: verificationCallbackUrl | ||||||||||||||
| ? new URL(verificationCallbackUrl, window.location.origin).toString() | ||||||||||||||
| : `${window.location.origin}/auth/verify-email`, | ||||||||||||||
|
Comment on lines
+22
to
+24
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. The current implementation replaces the email verification URL entirely with the
Suggested change
|
||||||||||||||
| }); | ||||||||||||||
|
|
||||||||||||||
| if (result.error) { | ||||||||||||||
|
|
||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| const DEFAULT_CALLBACK_URL = '/dashboard'; | ||
|
|
||
| export function normalizeCallbackUrl(callbackUrl: string | null): string { | ||
| if (!callbackUrl) return DEFAULT_CALLBACK_URL; | ||
| if (!callbackUrl.startsWith('/') || callbackUrl.startsWith('//')) { | ||
| return DEFAULT_CALLBACK_URL; | ||
| } | ||
|
|
||
| return callbackUrl; | ||
| } | ||
|
|
||
| export function appendCallbackUrl(path: string, callbackUrl: string): string { | ||
| const params = new URLSearchParams({ callbackUrl }); | ||
| return `${path}?${params.toString()}`; | ||
| } |
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.
Import
appendCallbackUrlto correctly construct the email verification URL with the target callback destination.