async function signupUser() { const name = document.getElementById('name')?.value?.trim() || ''; const email = document.getElementById('email')?.value?.trim() || ''; const phone = document.getElementById('phone')?.value?.trim() || ''; const password = document.getElementById('password')?.value || ''; if (!name || !email || !password) { showToast('Please fill in all required fields', 'warning'); return; } try { const res = await fetch('/api/auth/signup', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ name, email, phone, password }) }); const data = await res.json().catch(() => ({})); if (!res.ok) { showToast(`Signup failed: ${data.detail || data.error || 'Unknown error'}`, 'error'); return; } // Email verification required — show message, do NOT log in if (data.email_verification_required) { const container = document.getElementById('signupForm')?.closest('.auth-box') || document.querySelector('.auth-box'); if (container) { container.innerHTML = `
We've sent a verification link to
${escapeHtml ? escapeHtml(email) : email}
Click the link in the email to activate your account.
Didn't receive it?
Resend verification email