diff --git a/src/components/auth/AuthButtons.tsx b/src/components/auth/AuthButtons.tsx index 23bb47d0..b08b6092 100644 --- a/src/components/auth/AuthButtons.tsx +++ b/src/components/auth/AuthButtons.tsx @@ -76,7 +76,6 @@ export function AuthButtons() { src={profile?.avatar_url || undefined} alt={profile?.display_name || profile?.username || user.email || 'User avatar'} onError={(e) => { - console.warn('[Avatar] Failed to load image:', profile?.avatar_url); e.currentTarget.src = ''; // Force fallback }} /> diff --git a/src/components/auth/AuthModal.tsx b/src/components/auth/AuthModal.tsx index 2a556352..5944bf9b 100644 --- a/src/components/auth/AuthModal.tsx +++ b/src/components/auth/AuthModal.tsx @@ -99,8 +99,6 @@ export function AuthModal({ open, onOpenChange, defaultTab = 'signin' }: AuthMod const postAuthResult = await handlePostAuthFlow(data.session, 'password'); if (postAuthResult.success && postAuthResult.data.shouldRedirect) { - console.log('[AuthModal] MFA step-up required'); - // Get the TOTP factor ID const { data: factors } = await supabase.auth.mfa.listFactors(); const totpFactor = factors?.totp?.find(f => f.status === 'verified'); diff --git a/src/components/auth/TOTPSetup.tsx b/src/components/auth/TOTPSetup.tsx index c8aa9299..2fbf53b7 100644 --- a/src/components/auth/TOTPSetup.tsx +++ b/src/components/auth/TOTPSetup.tsx @@ -125,7 +125,6 @@ export function TOTPSetup() { const isOAuthUser = authMethod === 'oauth'; if (isOAuthUser) { - console.log('[TOTPSetup] OAuth user enrolled MFA, triggering step-up...'); setStepUpRequired(true, window.location.pathname); navigate('/auth/mfa-step-up'); return; diff --git a/src/components/moderation/PhotoSubmissionDisplay.tsx b/src/components/moderation/PhotoSubmissionDisplay.tsx index 39182aca..ed0b141b 100644 --- a/src/components/moderation/PhotoSubmissionDisplay.tsx +++ b/src/components/moderation/PhotoSubmissionDisplay.tsx @@ -19,69 +19,36 @@ export function PhotoSubmissionDisplay({ submissionId }: PhotoSubmissionDisplayP }, [submissionId]); const fetchPhotos = async () => { - console.log('🖼️ PhotoSubmissionDisplay: Starting fetch for submission:', submissionId); - try { - // Check user auth and roles - const { data: session } = await supabase.auth.getSession(); - const userId = session?.session?.user?.id; - console.log('👤 Current user ID:', userId); - - if (userId) { - const { data: roles } = await supabase - .from('user_roles') - .select('role') - .eq('user_id', userId); - console.log('👤 Current user roles:', roles); - } - // Step 1: Get photo_submission_id from submission_id - console.log('📸 Step 1: Querying photo_submissions table...'); const { data: photoSubmission, error: photoSubmissionError } = await supabase .from('photo_submissions') .select('id, entity_type, title') .eq('submission_id', submissionId) .maybeSingle(); - console.log('📸 Photo submission query result:', { - photoSubmission, - error: photoSubmissionError - }); - if (photoSubmissionError) { - console.error('❌ Error fetching photo_submission:', photoSubmissionError); throw photoSubmissionError; } if (!photoSubmission) { - console.log('⚠️ No photo_submission found for submission_id:', submissionId); setPhotos([]); setLoading(false); return; } - console.log('✅ Found photo_submission ID:', photoSubmission.id); - // Step 2: Get photo items using photo_submission_id - console.log('🖼️ Step 2: Querying photo_submission_items table...'); const { data, error } = await supabase .from('photo_submission_items') .select('*') .eq('photo_submission_id', photoSubmission.id) .order('order_index'); - console.log('🖼️ Photo items query result:', { - itemCount: data?.length, - error - }); - if (error) { - console.error('❌ Error fetching photo_submission_items:', error); throw error; } setPhotos(data || []); - console.log(`✅ Successfully loaded ${data?.length || 0} photos`); } catch (error: unknown) { const errorMsg = getErrorMessage(error); console.error('❌ PhotoSubmissionDisplay error:', errorMsg); diff --git a/src/components/moderation/QueueSortControls.tsx b/src/components/moderation/QueueSortControls.tsx index 0a6975ad..af5940ab 100644 --- a/src/components/moderation/QueueSortControls.tsx +++ b/src/components/moderation/QueueSortControls.tsx @@ -27,18 +27,15 @@ export const QueueSortControls = ({ const validFields: SortField[] = ['created_at', 'submission_type', 'status']; if (!validFields.includes(value as SortField)) { - console.warn('⚠️ [SORT] Invalid sort field:', value); return; } const field = value as SortField; - console.log('🔄 [SORT] Field change:', { from: sortConfig.field, to: field }); onSortChange({ ...sortConfig, field }); }; const handleDirectionToggle = () => { const newDirection = sortConfig.direction === 'asc' ? 'desc' : 'asc'; - console.log('🔄 [SORT] Direction toggle:', { from: sortConfig.direction, to: newDirection }); onSortChange({ ...sortConfig, direction: newDirection diff --git a/src/components/moderation/ReportsQueue.tsx b/src/components/moderation/ReportsQueue.tsx index 330d5723..ca9d26b5 100644 --- a/src/components/moderation/ReportsQueue.tsx +++ b/src/components/moderation/ReportsQueue.tsx @@ -6,6 +6,7 @@ import { Card, CardContent, CardHeader } from '@/components/ui/card'; import { Textarea } from '@/components/ui/textarea'; import { Label } from '@/components/ui/label'; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select'; +import { logger } from '@/lib/logger'; import { Pagination, PaginationContent, @@ -128,7 +129,7 @@ export const ReportsQueue = forwardRef((props, ref) => { return JSON.parse(saved); } } catch (error) { - console.warn('Failed to load sort config from localStorage:', error); + logger.warn('Failed to load sort config from localStorage'); } return { field: 'created_at', direction: 'asc' as ReportSortDirection }; }); @@ -153,7 +154,7 @@ export const ReportsQueue = forwardRef((props, ref) => { try { localStorage.setItem('reportsQueue_sortConfig', JSON.stringify(sortConfig)); } catch (error) { - console.warn('Failed to save sort config to localStorage:', error); + logger.warn('Failed to save sort config to localStorage'); } }, [sortConfig]); diff --git a/src/components/moderation/SubmissionItemsList.tsx b/src/components/moderation/SubmissionItemsList.tsx index 7371aee2..008fea6a 100644 --- a/src/components/moderation/SubmissionItemsList.tsx +++ b/src/components/moderation/SubmissionItemsList.tsx @@ -6,6 +6,7 @@ import { Skeleton } from '@/components/ui/skeleton'; import { Alert, AlertDescription } from '@/components/ui/alert'; import { AlertCircle, Loader2 } from 'lucide-react'; import type { SubmissionItemData } from '@/types/submissions'; +import { logger } from '@/lib/logger'; interface SubmissionItemsListProps { submissionId: string; @@ -54,7 +55,7 @@ export const SubmissionItemsList = memo(function SubmissionItemsList({ .eq('submission_id', submissionId); if (photoError) { - console.warn('Error checking photo submissions:', photoError); + logger.warn('Error checking photo submissions:', photoError); } setItems((itemsData || []) as SubmissionItemData[]); diff --git a/src/components/search/SearchResults.tsx b/src/components/search/SearchResults.tsx index 1ca0b64a..0740f51e 100644 --- a/src/components/search/SearchResults.tsx +++ b/src/components/search/SearchResults.tsx @@ -85,7 +85,6 @@ export function SearchResults({ query, onClose }: SearchResultsProps) { break; case 'company': // Navigate to manufacturer page when implemented - console.log('Company clicked:', result.data); break; } }; diff --git a/src/components/settings/PrivacyTab.tsx b/src/components/settings/PrivacyTab.tsx index 25c19921..dff8da03 100644 --- a/src/components/settings/PrivacyTab.tsx +++ b/src/components/settings/PrivacyTab.tsx @@ -72,9 +72,7 @@ export function PrivacyTab() { ...parseResult.data }); } else { - console.warn('Invalid privacy settings, reinitializing with defaults', { - errors: parseResult.error.issues - }); + logger.warn('Invalid privacy settings, reinitializing with defaults'); await initializePreferences(); } } else { diff --git a/src/components/upload/EntityPhotoGallery.tsx b/src/components/upload/EntityPhotoGallery.tsx index 6fff34a6..8a5a47ef 100644 --- a/src/components/upload/EntityPhotoGallery.tsx +++ b/src/components/upload/EntityPhotoGallery.tsx @@ -50,8 +50,6 @@ export function EntityPhotoGallery({ const fetchPhotos = async () => { try { - console.log('📷 [FETCH PHOTOS] Starting fetch for:', { entityId, entityType }); - // Fetch photos directly from the photos table const { data: photoData, error } = await supabase .from('photos') @@ -60,8 +58,6 @@ export function EntityPhotoGallery({ .eq('entity_id', entityId) .order('created_at', { ascending: sortBy === 'oldest' }); - console.log('📷 [FETCH PHOTOS] Query result:', { photoData, error, count: photoData?.length }); - if (error) throw error; // Map to Photo interface @@ -74,7 +70,6 @@ export function EntityPhotoGallery({ created_at: photo.created_at, })) || []; - console.log('📷 [FETCH PHOTOS] Mapped photos:', mappedPhotos); setPhotos(mappedPhotos); } catch (error: unknown) { console.error('📷 [FETCH PHOTOS] Error:', error); diff --git a/src/components/upload/PhotoUpload.tsx b/src/components/upload/PhotoUpload.tsx index 654aaaa0..b04893c3 100644 --- a/src/components/upload/PhotoUpload.tsx +++ b/src/components/upload/PhotoUpload.tsx @@ -17,6 +17,7 @@ import { getErrorMessage } from '@/lib/errorHandler'; import { supabase } from '@/integrations/supabase/client'; import { invokeWithTracking } from '@/lib/edgeFunctionTracking'; import { useAuth } from '@/hooks/useAuth'; +import { logger } from '@/lib/logger'; interface PhotoUploadProps { onUploadComplete?: (urls: string[], imageId?: string) => void; @@ -250,7 +251,7 @@ export function PhotoUpload({ 'DELETE' ); } catch (deleteError) { - console.warn('Failed to delete old avatar:', deleteError); + logger.warn('Failed to delete old avatar'); } } diff --git a/src/components/upload/UppyPhotoSubmissionUpload.tsx b/src/components/upload/UppyPhotoSubmissionUpload.tsx index 2918f332..ba2bb007 100644 --- a/src/components/upload/UppyPhotoSubmissionUpload.tsx +++ b/src/components/upload/UppyPhotoSubmissionUpload.tsx @@ -232,14 +232,6 @@ export function UppyPhotoSubmissionUpload({ throw itemsError; } - console.log('✅ Photo submission created:', { - submission_id: submissionData.id, - photo_submission_id: photoSubmissionData.id, - entity_type: entityType, - entity_id: entityId, - photo_count: photoItems.length, - }); - toast({ title: 'Submission Successful', description: 'Your photos have been submitted for review. Thank you for contributing!', diff --git a/src/hooks/useAuth.tsx b/src/hooks/useAuth.tsx index 69a92443..8365bbc9 100644 --- a/src/hooks/useAuth.tsx +++ b/src/hooks/useAuth.tsx @@ -110,7 +110,6 @@ function AuthProviderComponent({ children }: { children: React.ReactNode }) { const currentAal = await getSessionAal(session); setAal(currentAal); authLog('[Auth] Current AAL:', currentAal); - console.log('🔐 [Auth] AAL SET:', currentAal); // Explicit console log for debugging } else { setAal(null); } diff --git a/src/hooks/useCaptchaBypass.ts b/src/hooks/useCaptchaBypass.ts index 72ec1569..65c1b7ef 100644 --- a/src/hooks/useCaptchaBypass.ts +++ b/src/hooks/useCaptchaBypass.ts @@ -1,17 +1,15 @@ import { useEffect } from 'react'; +import { logger } from '@/lib/logger'; export function useCaptchaBypass() { // Single layer: Check if environment allows bypass const bypassEnabled = import.meta.env.VITE_ALLOW_CAPTCHA_BYPASS === 'true'; - // Log warning if bypass is active useEffect(() => { if (bypassEnabled && typeof window !== 'undefined') { - console.warn( - '⚠️ CAPTCHA BYPASS IS ACTIVE\n' + - 'CAPTCHA verification is disabled via VITE_ALLOW_CAPTCHA_BYPASS=true\n' + - 'This should ONLY be enabled in development/preview environments.\n' + - 'Ensure VITE_ALLOW_CAPTCHA_BYPASS=false in production!' + logger.warn( + '⚠️ CAPTCHA BYPASS IS ACTIVE - ' + + 'This should ONLY be enabled in development/preview environments.' ); } }, [bypassEnabled]); diff --git a/src/hooks/useEntityVersions.ts b/src/hooks/useEntityVersions.ts index 302af076..c1d8a9c1 100644 --- a/src/hooks/useEntityVersions.ts +++ b/src/hooks/useEntityVersions.ts @@ -3,6 +3,7 @@ import { supabase } from '@/integrations/supabase/client'; import { toast } from 'sonner'; import { getErrorMessage } from '@/lib/errorHandler'; import type { EntityType, EntityVersion } from '@/types/versioning'; +import { logger } from '@/lib/logger'; interface FieldChange { id: string; @@ -123,7 +124,7 @@ export function useEntityVersions(entityType: EntityType, entityId: string) { * @deprecated Use compareVersions() to see field-level changes */ const fetchFieldHistory = async (versionId: string) => { - console.warn('fetchFieldHistory is deprecated. Use compareVersions() instead for field-level changes.'); + logger.warn('fetchFieldHistory is deprecated. Use compareVersions() instead for field-level changes.'); setFieldHistory([]); }; diff --git a/src/hooks/useLocationAutoDetect.ts b/src/hooks/useLocationAutoDetect.ts index 0e3f5d65..3a7cea70 100644 --- a/src/hooks/useLocationAutoDetect.ts +++ b/src/hooks/useLocationAutoDetect.ts @@ -1,6 +1,7 @@ import { useEffect } from 'react'; import { useAuth } from '@/hooks/useAuth'; import { useUnitPreferences } from '@/hooks/useUnitPreferences'; +import { logger } from '@/lib/logger'; function isLocalStorageAvailable(): boolean { try { @@ -24,11 +25,11 @@ export function useLocationAutoDetect() { // Only run auto-detection after preferences have loaded if (loading) return; - // Check if localStorage is available - if (!isLocalStorageAvailable()) { - console.warn('localStorage is not available, skipping location auto-detection'); - return; - } + // Check if localStorage is available + if (!isLocalStorageAvailable()) { + logger.warn('localStorage is not available, skipping location auto-detection'); + return; + } // Check if we've already attempted detection const hasAttemptedDetection = localStorage.getItem('location_detection_attempted'); diff --git a/src/hooks/useModerationQueue.ts b/src/hooks/useModerationQueue.ts index 8735b10d..d733d588 100644 --- a/src/hooks/useModerationQueue.ts +++ b/src/hooks/useModerationQueue.ts @@ -435,7 +435,6 @@ export const useModerationQueue = (config?: UseModerationQueueConfig) => { const releaseAfterAction = useCallback(async (submissionId: string, action: 'approved' | 'rejected'): Promise => { if (currentLock?.submissionId === submissionId) { await releaseLock(submissionId, true); // Silent release - console.log(`🔓 Auto-released lock after ${action} action`); } }, [currentLock, releaseLock]); diff --git a/src/hooks/useProfile.tsx b/src/hooks/useProfile.tsx index 5b63f65d..0b4628f2 100644 --- a/src/hooks/useProfile.tsx +++ b/src/hooks/useProfile.tsx @@ -11,8 +11,6 @@ export function useProfile(userId: string | undefined) { queryFn: async () => { if (!userId) return null; - console.log('[useProfile] Fetching filtered profile for userId:', userId); - // Get current viewer ID const { data: { user } } = await supabase.auth.getUser(); const viewerId = user?.id || null; @@ -24,7 +22,6 @@ export function useProfile(userId: string | undefined) { }); if (error) { - console.error('[useProfile] Error:', error); throw error; } @@ -46,11 +43,6 @@ export function useProfile(userId: string | undefined) { } } - console.log('[useProfile] Filtered profile loaded:', { - username: profileData.username, - has_avatar: !!profileData.avatar_url - }); - return profileData; }, enabled: !!userId, @@ -61,7 +53,6 @@ export function useProfile(userId: string | undefined) { const refreshProfile = () => { if (userId) { - console.log('[useProfile] Invalidating profile cache for userId:', userId); queryClient.invalidateQueries({ queryKey: ['profile', userId] }); } }; diff --git a/src/hooks/useSearch.tsx b/src/hooks/useSearch.tsx index 610c9530..13a20851 100644 --- a/src/hooks/useSearch.tsx +++ b/src/hooks/useSearch.tsx @@ -1,6 +1,7 @@ import { useState, useEffect, useMemo, useCallback } from 'react'; import { supabase } from '@/integrations/supabase/client'; import { Park, Ride, Company } from '@/types/database'; +import { logger } from '@/lib/logger'; export interface SearchResult { id: string; @@ -67,7 +68,7 @@ export function useSearch(options: UseSearchOptions = {}) { setRecentSearches(parsed); } else { // Invalid format, clear it - console.warn('Recent searches data is not an array, clearing'); + logger.warn('Recent searches data is not an array, clearing'); localStorage.removeItem('thrillwiki_recent_searches'); } } catch (parseError) { diff --git a/src/lib/entityValidationSchemas.ts b/src/lib/entityValidationSchemas.ts index 66537270..f5391141 100644 --- a/src/lib/entityValidationSchemas.ts +++ b/src/lib/entityValidationSchemas.ts @@ -451,8 +451,6 @@ async function checkSlugUniqueness( const tableName = getTableNameFromEntityType(entityType); try { - console.log(`Checking slug uniqueness for "${slug}" in ${tableName}, excludeId: ${excludeId}`); - // Query with explicit table name - use simple approach to avoid type instantiation issues let result; @@ -470,34 +468,28 @@ async function checkSlugUniqueness( result = await supabase.from('ride_models').select('id').eq('slug', slug).limit(1); break; default: - console.error(`Invalid table name: ${tableName}`); return true; // Assume unique on invalid table } const { data, error } = result; if (error) { - console.error(`Slug uniqueness check failed for ${entityType}:`, error); return true; // Assume unique on error to avoid blocking } // If no data, slug is unique if (!data || data.length === 0) { - console.log(`Slug "${slug}" is unique in ${tableName}`); return true; } // If excludeId provided and matches, it's the same entity (editing) if (excludeId && data[0] && data[0].id === excludeId) { - console.log(`Slug "${slug}" matches current entity (editing mode)`); return true; } // Slug is in use by a different entity - console.log(`Slug "${slug}" already exists in ${tableName}`); return false; } catch (error) { - console.error(`Exception during slug uniqueness check:`, error); return true; // Assume unique on error to avoid false positives } } diff --git a/src/lib/moderationStateMachine.ts b/src/lib/moderationStateMachine.ts index edd3fcf9..efda6043 100644 --- a/src/lib/moderationStateMachine.ts +++ b/src/lib/moderationStateMachine.ts @@ -4,6 +4,7 @@ */ import type { SubmissionItemWithDeps } from './submissionItemsService'; +import { logger } from './logger'; // State definitions using discriminated unions export type ModerationState = @@ -63,7 +64,7 @@ export function moderationReducer( case 'LOCK_EXPIRED': if (state.status !== 'locked' && state.status !== 'reviewing' && state.status !== 'loading_data') { - console.warn(`Lock expired notification in unexpected state: ${state.status}`); + logger.warn(`Lock expired notification in unexpected state: ${state.status}`); return state; } return { @@ -123,7 +124,7 @@ export function moderationReducer( case 'ERROR': // Error can happen from most states if (state.status === 'idle' || state.status === 'complete') { - console.warn('Error action in terminal state'); + logger.warn('Error action in terminal state'); return state; } return { @@ -135,7 +136,7 @@ export function moderationReducer( case 'RELEASE_LOCK': // Can release lock from locked, reviewing, or error states if (state.status !== 'locked' && state.status !== 'reviewing' && state.status !== 'error' && state.status !== 'lock_expired' && state.status !== 'loading_data') { - console.warn(`Cannot release lock from state: ${state.status}`); + logger.warn(`Cannot release lock from state: ${state.status}`); return state; } return { status: 'idle' }; diff --git a/src/lib/submissionChangeDetection.ts b/src/lib/submissionChangeDetection.ts index ff4ca75a..41f91338 100644 --- a/src/lib/submissionChangeDetection.ts +++ b/src/lib/submissionChangeDetection.ts @@ -379,7 +379,7 @@ export async function detectChanges( // Add debugging warning if critical data is missing if (!itemData.entity_name && item.item_type === 'photo_delete') { - console.warn(`[Photo Delete] Missing entity_name for photo_delete item`, { + logger.warn('[Photo Delete] Missing entity_name for photo_delete item', { item_type: item.item_type, has_entity_type: !!itemData.entity_type, has_entity_id: !!itemData.entity_id, diff --git a/src/lib/submissionItemsService.ts b/src/lib/submissionItemsService.ts index e3694f1d..e965c9a3 100644 --- a/src/lib/submissionItemsService.ts +++ b/src/lib/submissionItemsService.ts @@ -1089,10 +1089,12 @@ export async function editSubmissionItem( currentItem.submission_id, true // isEdit = true ); - - console.log(`✅ Created version for manual edit of ${currentItem.item_type} ${currentItem.approved_entity_id}`); } catch (versionError) { - console.error('Failed to create version for manual edit:', versionError); + logger.error('Failed to create version for manual edit', { + action: 'create_version_for_edit', + itemType: currentItem.item_type, + entityId: currentItem.approved_entity_id + }); // Don't fail the entire operation, just log the error // The edit itself is still saved, just without version history } diff --git a/src/lib/viewTracking.ts b/src/lib/viewTracking.ts index 185885b3..363c441f 100644 --- a/src/lib/viewTracking.ts +++ b/src/lib/viewTracking.ts @@ -1,4 +1,5 @@ import { supabase } from '@/integrations/supabase/client'; +import { logger } from './logger'; // Generate anonymous session hash (no PII) function getSessionHash(): string { @@ -38,10 +39,8 @@ export async function trackPageView( entity_id: entityId, session_hash: getSessionHash() }); - - console.log(`✅ Tracked view: ${entityType} ${entityId}`); } catch (error) { // Fail silently - don't break the page if tracking fails - console.error('Failed to track page view:', error); + logger.error('Failed to track page view', { entityType, entityId }); } } diff --git a/src/pages/Auth.tsx b/src/pages/Auth.tsx index f682c073..6b8a99c1 100644 --- a/src/pages/Auth.tsx +++ b/src/pages/Auth.tsx @@ -89,11 +89,6 @@ export default function Auth() { setSignInCaptchaToken(null); try { - console.log('[Auth] Attempting sign in...', { - email: formData.email, - timestamp: new Date().toISOString(), - }); - const { data, error @@ -109,7 +104,6 @@ export default function Auth() { // Check if MFA is required (user exists but no session) if (data.user && !data.session) { - console.log('[Auth] MFA required'); const totpFactor = data.user.factors?.find(f => f.factor_type === 'totp' && f.status === 'verified'); if (totpFactor) { @@ -127,8 +121,6 @@ export default function Auth() { const postAuthResult = await handlePostAuthFlow(data.session, 'password'); if (postAuthResult.success && postAuthResult.data.shouldRedirect) { - console.log('[Auth] MFA step-up required'); - // Get the TOTP factor ID const { data: factors } = await supabase.auth.mfa.listFactors(); const totpFactor = factors?.totp?.find(f => f.status === 'verified'); @@ -140,24 +132,16 @@ export default function Auth() { } } - console.log('[Auth] Sign in successful', { - user: data.user?.email, - session: !!data.session, - sessionExpiry: data.session?.expires_at - }); - // Verify session was stored setTimeout(async () => { const { data: { session } } = await supabase.auth.getSession(); if (!session) { - console.error('[Auth] Session not found after login!'); toast({ variant: "destructive", title: "Session Error", description: "Login succeeded but session was not stored. Please check your browser settings and enable cookies/storage." }); } else { - console.log('[Auth] Session verified after login'); toast({ title: "Welcome back!", description: "You've been signed in successfully." @@ -447,18 +431,9 @@ export default function Auth() { { - console.log('Sign-in CAPTCHA success:', token); - setSignInCaptchaToken(token); - }} - onError={(error) => { - console.log('Sign-in CAPTCHA error:', error); - setSignInCaptchaToken(null); - }} - onExpire={() => { - console.log('Sign-in CAPTCHA expired'); - setSignInCaptchaToken(null); - }} + onSuccess={setSignInCaptchaToken} + onError={() => setSignInCaptchaToken(null)} + onExpire={() => setSignInCaptchaToken(null)} siteKey={import.meta.env.VITE_TURNSTILE_SITE_KEY} theme="auto" /> diff --git a/src/pages/AuthCallback.tsx b/src/pages/AuthCallback.tsx index 16b8c17a..d3d4a843 100644 --- a/src/pages/AuthCallback.tsx +++ b/src/pages/AuthCallback.tsx @@ -30,7 +30,6 @@ export default function AuthCallback() { // Check if this is a password recovery flow first const hash = window.location.hash; if (hash.includes('type=recovery')) { - console.log('[AuthCallback] Password recovery detected'); setIsRecoveryMode(true); setStatus('success'); // Stop the loading spinner return; // Don't process further @@ -40,19 +39,15 @@ export default function AuthCallback() { const { data: { session }, error: sessionError } = await supabase.auth.getSession(); if (sessionError) { - console.error('[AuthCallback] Session error:', sessionError); throw sessionError; } if (!session) { - console.log('[AuthCallback] No session found, redirecting to auth'); navigate('/auth'); return; } const user = session.user; - console.log('[AuthCallback] User authenticated:', user.id); - // Check if this is a new OAuth user (created within last minute) const createdAt = new Date(user.created_at); @@ -63,20 +58,11 @@ export default function AuthCallback() { const provider = user.app_metadata?.provider; const isOAuthUser = provider === 'google' || provider === 'discord'; - console.log('[AuthCallback] User info:', { - isNewUser, - isOAuthUser, - provider, - createdAt: user.created_at, - }); - // If new OAuth user, process profile if (isNewUser && isOAuthUser) { setStatus('processing'); try { - console.log('[AuthCallback] Processing OAuth profile...'); - const { data, error, requestId } = await invokeWithTracking( 'process-oauth-profile', {}, @@ -84,13 +70,9 @@ export default function AuthCallback() { ); if (error) { - console.error('[AuthCallback] Profile processing error:', error); // Don't throw - allow sign-in to continue even if profile processing fails - } else { - console.log('[AuthCallback] Profile processed:', data); } } catch (error) { - console.error('[AuthCallback] Failed to process profile:', error); // Continue anyway - don't block sign-in } } @@ -100,16 +82,11 @@ export default function AuthCallback() { if (isOAuthUser) { authMethod = 'oauth'; } - - console.log('[AuthCallback] Auth method:', authMethod); // Unified post-authentication flow for ALL methods (OAuth, magic link, etc.) - console.log('[AuthCallback] Running post-auth flow...'); const result = await handlePostAuthFlow(session, authMethod); if (result.success && result.data?.shouldRedirect) { - console.log('[AuthCallback] MFA step-up required - showing modal'); - // Get factor ID and show modal instead of redirecting const { data: factors } = await supabase.auth.mfa.listFactors(); const totpFactor = factors?.totp?.find(f => f.status === 'verified'); @@ -138,7 +115,6 @@ export default function AuthCallback() { } catch (error) { const errorMsg = getErrorMessage(error); - console.error('[AuthCallback] Error:', errorMsg); setStatus('error'); toast({ @@ -224,7 +200,6 @@ export default function AuthCallback() { } catch (error) { const errorMsg = getErrorMessage(error); - console.error('[AuthCallback] Password reset error:', errorMsg); toast({ variant: 'destructive', title: 'Failed to set password',