-
Notifications
You must be signed in to change notification settings - Fork 0
Fix email input field issues in onboarding #244
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
base: main
Are you sure you want to change the base?
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 |
|---|---|---|
|
|
@@ -94,6 +94,12 @@ export default function OnboardingPage() { | |
|
|
||
| if (session?.user?.email) { | ||
| handleSessionEstablished(session.user.email) | ||
| } else if (session?.user && !session.user.email) { | ||
| // Session exists but email is missing - clear the bad state | ||
| console.error('Auth state change: Session without email detected', session.user) | ||
| setValue('email', '') | ||
| setEmailLocked(false) | ||
| void supabase.auth.signOut() // Clear the problematic session | ||
| } else if (session === null) { | ||
| // Clear email if user signs out (e.g., in another tab) | ||
| setValue('email', '') | ||
|
|
@@ -117,6 +123,20 @@ export default function OnboardingPage() { | |
|
|
||
| if (session?.user?.email) { | ||
| handleSessionEstablished(session.user.email) | ||
| } else if (session?.user && !session.user.email) { | ||
| // Session exists but email is missing - this is an error state | ||
| console.error('Session found but email is missing:', session.user) | ||
| if (isMounted) { | ||
| setEmailLocked(false) // Ensure field is not locked | ||
| setIsCheckingAuth(false) | ||
| toast({ | ||
| variant: 'destructive', | ||
| title: 'Authentication Issue', | ||
| description: 'Your session is missing email information. Please try signing in again.' | ||
| }) | ||
| // Clear the problematic session | ||
| void supabase.auth.signOut() | ||
| } | ||
| } else { | ||
| // No session found, set timeout to allow for magic link processing | ||
| timeoutId = setTimeout(() => { | ||
|
|
@@ -318,6 +338,11 @@ export default function OnboardingPage() { | |
| <Label htmlFor='email'>Email</Label> | ||
| <Input | ||
| id='email' | ||
| type='email' | ||
| autoComplete='email' | ||
| autoCapitalize='none' | ||
| autoCorrect='off' | ||
| spellCheck='false' | ||
| {...register('email', { | ||
| required: 'Email is required', | ||
| pattern: { | ||
|
|
@@ -374,6 +399,11 @@ export default function OnboardingPage() { | |
| Sign in with Google | ||
| </Button> | ||
| </form> | ||
| {debugInfo && ( | ||
|
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 debugInfo variable is used in the JSX but isn’t defined in this diff. Ensure that debug mode logic (e.g., reading ?debug=true) sets and passes debugInfo appropriately. |
||
| <div className='mt-4 p-2 bg-gray-100 rounded text-xs font-mono whitespace-pre-wrap'> | ||
| Debug Info:{debugInfo} | ||
| </div> | ||
| )} | ||
|
Comment on lines
+402
to
+406
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 variable |
||
| </CardContent> | ||
| </Card> | ||
| </div> | ||
|
|
||
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.
The logic here to handle a session without an email is inconsistent with the similar logic in
checkSession(lines 126-140). This implementation is missing a user-facing notification (toast) and doesn't update theisCheckingAuthstate, which could leave the UI in a loading state or cause confusion for the user.To ensure consistent behavior, this block should also show a toast message and set
isCheckingAuthtofalse. For better maintainability, consider refactoring this duplicated logic into a single helper function.