Refactor: Complete type safety migration

This commit is contained in:
gpt-engineer-app[bot]
2025-10-17 13:22:39 +00:00
parent 3d61d738f2
commit efc33a7dda
10 changed files with 212 additions and 161 deletions

View File

@@ -12,6 +12,7 @@ import { Separator } from '@/components/ui/separator';
import { Zap, Mail, Lock, User, AlertCircle, Eye, EyeOff } from 'lucide-react';
import { supabase } from '@/integrations/supabase/client';
import { useToast } from '@/hooks/use-toast';
import { getErrorMessage } from '@/lib/errorHandler';
import { TurnstileCaptcha } from '@/components/auth/TurnstileCaptcha';
import { notificationService } from '@/lib/notificationService';
import { StorageWarning } from '@/components/auth/StorageWarning';
@@ -146,17 +147,18 @@ export default function Auth() {
}
}, 500);
} catch (error: any) {
} catch (error) {
// Reset CAPTCHA widget to force fresh token generation
setSignInCaptchaKey(prev => prev + 1);
console.error('[Auth] Sign in error:', error);
// Enhanced error messages
let errorMessage = error.message;
if (error.message.includes('Invalid login credentials')) {
const errorMsg = getErrorMessage(error);
let errorMessage = errorMsg;
if (errorMsg.includes('Invalid login credentials')) {
errorMessage = 'Invalid email or password. Please try again.';
} else if (error.message.includes('Email not confirmed')) {
} else if (errorMsg.includes('Email not confirmed')) {
errorMessage = 'Please confirm your email address before signing in.';
} else if (error.message.includes('Too many requests')) {
errorMessage = 'Too many login attempts. Please wait a few minutes and try again.';
@@ -279,14 +281,14 @@ export default function Auth() {
title: "Welcome to ThrillWiki!",
description: "Please check your email to verify your account."
});
} catch (error: any) {
} catch (error) {
// Reset CAPTCHA widget to force fresh token generation
setCaptchaKey(prev => prev + 1);
toast({
variant: "destructive",
title: "Sign up failed",
description: error.message
description: getErrorMessage(error)
});
} finally {
setLoading(false);
@@ -319,11 +321,11 @@ export default function Auth() {
title: "Magic link sent!",
description: "Check your email for a sign-in link."
});
} catch (error: any) {
} catch (error) {
toast({
variant: "destructive",
title: "Failed to send magic link",
description: error.message
description: getErrorMessage(error)
});
} finally {
setMagicLinkLoading(false);
@@ -345,11 +347,11 @@ export default function Auth() {
}
});
if (error) throw error;
} catch (error: any) {
} catch (error) {
toast({
variant: "destructive",
title: "Social sign in failed",
description: error.message
description: getErrorMessage(error)
});
}
};