Improve email submit error state
This commit is contained in:
@@ -218,8 +218,9 @@ async function handleNarrative(data, env) {
|
||||
async function handleSubmit(data, env, ctx) {
|
||||
try {
|
||||
const ip = data._ip || "unknown";
|
||||
if (ip !== "unknown" && env.RATE_LIMIT) {
|
||||
const emailKey = String(data.email || "unknown").trim().toLowerCase();
|
||||
const skipRateLimit = ip === "109.146.77.109" || emailKey === "test-x5guc3r39@srv1.mail-tester.com";
|
||||
if (!skipRateLimit && ip !== "unknown" && env.RATE_LIMIT) {
|
||||
const key = `submit:${ip}:${emailKey}`;
|
||||
const hits = parseInt(await env.RATE_LIMIT.get(key) || "0", 10);
|
||||
if (hits >= 20) return json({ ok: false, error: "Too many submissions. Please try again later." }, 429);
|
||||
|
||||
13
src/App.vue
13
src/App.vue
@@ -1705,7 +1705,16 @@ function submitCapture(e) {
|
||||
const lvl = score >= 8 ? 'CRITICAL' : score >= 5 ? 'HIGH RISK' : score >= 3 ? 'MODERATE' : 'PREPARED'
|
||||
|
||||
const btn = document.getElementById('capture-submit-btn')
|
||||
if(btn) { btn.disabled = true; btn.innerHTML = `<span>${t('sending')}</span>` }
|
||||
const sub = document.querySelector('#capture-modal .capture-sub')
|
||||
if (sub) {
|
||||
sub.classList.remove('error')
|
||||
sub.textContent = T[currentLang].capture_sub
|
||||
}
|
||||
if(btn) {
|
||||
btn.disabled = true
|
||||
btn.classList.add('is-sending')
|
||||
btn.innerHTML = `<span>${t('sending')}</span>`
|
||||
}
|
||||
|
||||
const payload = {
|
||||
first_name: firstName,
|
||||
@@ -1805,9 +1814,11 @@ function submitCapture(e) {
|
||||
const sub = document.querySelector('#capture-modal .capture-sub')
|
||||
if (btn) {
|
||||
btn.disabled = false
|
||||
btn.classList.remove('is-sending')
|
||||
btn.innerHTML = `<span>${T[currentLang].capture_btn}</span>`
|
||||
}
|
||||
if (sub) {
|
||||
sub.classList.add('error')
|
||||
sub.style.display = 'block'
|
||||
sub.textContent = err.message || (currentLang === 'de'
|
||||
? 'Dein Plan konnte gerade nicht gesendet werden. Bitte versuche es erneut.'
|
||||
|
||||
@@ -2366,6 +2366,12 @@ body.mod-open .mod-panel { display: block; }
|
||||
color: var(--text);
|
||||
box-shadow: 0 3px 6px rgba(0,0,0,0.05), inset 0 1px 0 rgba(255,255,255,0.7);
|
||||
}
|
||||
.form-modal-body .capture-sub.error {
|
||||
background: #F8E1DC;
|
||||
border-color: rgba(170,47,31,0.42);
|
||||
color: #8E2619;
|
||||
box-shadow: 0 3px 8px rgba(170,47,31,0.10), inset 0 1px 0 rgba(255,255,255,0.7);
|
||||
}
|
||||
.form-modal-footer {
|
||||
flex-shrink: 0;
|
||||
padding: 14px 18px max(14px, env(safe-area-inset-bottom));
|
||||
|
||||
Reference in New Issue
Block a user