diff --git a/src/app/page.tsx b/src/app/page.tsx index 740799d..aea8f00 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -12,8 +12,67 @@ import FaqSplitText from '@/components/sections/faq/FaqSplitText'; import ContactFaq from '@/components/sections/contact/ContactFaq'; import FooterSimple from '@/components/sections/footer/FooterSimple'; import { Lock, BarChart3, CreditCard, Zap, Shield, Eye, History, FileText, Send, CheckCircle, TrendingUp, Calendar, ArrowRight } from 'lucide-react'; +import { useState } from 'react'; export default function LandingPage() { + const [loginEmail, setLoginEmail] = useState(''); + const [loginPassword, setLoginPassword] = useState(''); + const [loginError, setLoginError] = useState(''); + const [loginSuccess, setLoginSuccess] = useState(false); + + const handleLoginSubmit = async (e: React.FormEvent) => { + e.preventDefault(); + setLoginError(''); + setLoginSuccess(false); + + // Client-side validation + if (!loginEmail || !loginPassword) { + setLoginError('Please enter both email and password.'); + return; + } + + if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(loginEmail)) { + setLoginError('Please enter a valid email address.'); + return; + } + + try { + // Send login request to secure backend endpoint + const response = await fetch('/api/auth/login', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + // CSRF token should be included for additional security + }, + body: JSON.stringify({ + email: loginEmail, + password: loginPassword, + }), + // Ensure credentials are sent securely over HTTPS only + credentials: 'include', + }); + + if (!response.ok) { + const errorData = await response.json(); + setLoginError(errorData.message || 'Login failed. Please try again.'); + return; + } + + const data = await response.json(); + setLoginSuccess(true); + setLoginEmail(''); + setLoginPassword(''); + + // Redirect to dashboard after successful login + if (data.redirectUrl) { + window.location.href = data.redirectUrl; + } + } catch (error) { + setLoginError('An error occurred. Please try again.'); + console.error('Login error:', error); + } + }; + return ( + + {/* Secure Login Form */} +
+
+

Secure Login

+ +
+ {/* Email Input */} +
+ + setLoginEmail(e.target.value)} + placeholder="you@example.com" + className="w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent" + required + autoComplete="email" + /> +
+ + {/* Password Input */} +
+ + setLoginPassword(e.target.value)} + placeholder="••••••••" + className="w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent" + required + autoComplete="current-password" + /> +
+ + {/* Error Message */} + {loginError && ( +
+ {loginError} +
+ )} + + {/* Success Message */} + {loginSuccess && ( +
+ Login successful! Redirecting to your dashboard... +
+ )} + + {/* Submit Button */} + +
+ + {/* Security Notice */} +
+

+ + Your credentials are encrypted with 256-bit SSL and never stored in plain text. We never share your banking information. +

+
+
+