Skip to content

Commit f226f1c

Browse files
committed
Fix onboarding modal showing for unauthenticated users
- Add authentication check before showing onboarding modal - Only check onboarding status for authenticated users - Prevents modal from appearing when user is not logged in - Ensures proper user flow: login first, then onboarding if needed
1 parent bb926a4 commit f226f1c

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

app/page.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { SmartSearch } from '@/features/property-search/components/SmartSearch';
66
import { OnboardingModal } from '@/features/authentication/components/OnboardingModal';
77
import { AccountSetupService } from '@/features/authentication/services/account-setup-service';
88
import { PinsService } from '@/features/property-management/services/pins-service';
9+
import { useAuth } from '@/features/authentication/components/AuthProvider';
910

1011
import dynamic from 'next/dynamic';
1112

@@ -20,6 +21,7 @@ const MapboxMap = dynamic(() => import('@/features/property-search/components/Ma
2021
});
2122

2223
export default function HomePage() {
24+
const { user, loading } = useAuth();
2325
const [mapCenter] = useState({ lat: 39.8283, lng: -98.5795 }); // Center of continental United States
2426
const [showOnboarding, setShowOnboarding] = useState(false);
2527
const [isOnboardingComplete, setIsOnboardingComplete] = useState(false);
@@ -28,10 +30,18 @@ export default function HomePage() {
2830
const [showSmartSearch, setShowSmartSearch] = useState(true);
2931

3032
useEffect(() => {
31-
checkOnboardingStatus();
32-
}, []);
33+
// Only check onboarding status if user is authenticated
34+
if (!loading && user) {
35+
checkOnboardingStatus();
36+
}
37+
}, [user, loading]);
3338

3439
const checkOnboardingStatus = async () => {
40+
// Double-check that user is authenticated before proceeding
41+
if (!user) {
42+
return;
43+
}
44+
3545
const status = await AccountSetupService.checkAccountStatus();
3646
if (status.hasAccount && status.hasCredits) {
3747
setIsOnboardingComplete(true);

0 commit comments

Comments
 (0)