improve signup experience#37
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a utility for managing callback URLs and integrates it into the login, registration, and invitation flows to maintain user context across authentication steps. A critical issue was identified in the registration hook where the verification callback URL was overwriting the required email verification endpoint; suggestions were provided to correctly append the destination as a parameter instead.
| callbackURL: verificationCallbackUrl | ||
| ? new URL(verificationCallbackUrl, window.location.origin).toString() | ||
| : `${window.location.origin}/auth/verify-email`, |
There was a problem hiding this comment.
The current implementation replaces the email verification URL entirely with the verificationCallbackUrl. This will break the registration flow because the user will be directed to a page (like /dashboard or /invite/...) that does not handle the email verification token. Instead, the callbackURL sent to the auth provider should point to the verification endpoint, which then handles the redirection to the final destination.
| callbackURL: verificationCallbackUrl | |
| ? new URL(verificationCallbackUrl, window.location.origin).toString() | |
| : `${window.location.origin}/auth/verify-email`, | |
| callbackURL: verificationCallbackUrl | |
| ? appendCallbackUrl(`${window.location.origin}/auth/verify-email`, verificationCallbackUrl) | |
| : `${window.location.origin}/auth/verify-email`, |
| 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, | ||
| ) { |
There was a problem hiding this comment.
Import appendCallbackUrl to correctly construct the email verification URL with the target callback destination.
| 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, | |
| ) { | |
| import { useInvalidateMe } from '@/contexts/AuthContext'; | |
| import { authClient } from '@/lib/auth/client'; | |
| import { appendCallbackUrl } from '@/lib/auth/callback-url'; | |
| export function useRegisterForm( | |
| onSuccess: (email: string) => void, | |
| verificationCallbackUrl?: string, | |
| ) { |
No description provided.