diff --git a/app/mail/login/page.tsx b/app/mail/login/page.tsx index 6179d145..3782f9bd 100644 --- a/app/mail/login/page.tsx +++ b/app/mail/login/page.tsx @@ -7,7 +7,7 @@ import { Button } from '@/components/ui/button'; import { Input } from '@/components/ui/input'; import { Label } from '@/components/ui/label'; -export default function LoginPage() { +export default function MailLoginPage() { const router = useRouter(); const [email, setEmail] = useState(''); const [password, setPassword] = useState(''); @@ -22,8 +22,7 @@ export default function LoginPage() { setLoading(true); try { - // Test the connection first - const testResponse = await fetch('/api/mail/test-connection', { + const response = await fetch('/api/mail/login', { method: 'POST', headers: { 'Content-Type': 'application/json', @@ -36,30 +35,10 @@ export default function LoginPage() { }), }); - const testData = await testResponse.json(); + const data = await response.json(); - if (!testResponse.ok) { - throw new Error(testData.error || 'Failed to connect to email server'); - } - - // Store credentials using the API endpoint - const loginResponse = await fetch('/api/mail/login', { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ - email, - password, - host, - port, - }), - }); - - const loginData = await loginResponse.json(); - - if (!loginResponse.ok) { - throw new Error(loginData.error || 'Failed to store credentials'); + if (!response.ok) { + throw new Error(data.error || 'Failed to connect to email server'); } // Redirect to mail page @@ -75,7 +54,7 @@ export default function LoginPage() {