mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-22 17:51:12 -05:00
Refactor: Complete type safety migration
This commit is contained in:
@@ -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)
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user