Fix ALTCHA widget not loading or submitting

Two bugs prevented form submission entirely:
1. `challengeurl` attribute was renamed to `challenge` in altcha v3 — the
   widget silently ignored the old name so it never fetched a challenge.
2. `altchaWidget.value` is not an exposed property on the v3 custom element;
   read the solved payload from the hidden `<input name="altcha">` the widget
   renders in light DOM instead.

Also clears the err-altcha error message at the start of each submit attempt
so it doesn't linger after the user completes verification and retries.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
chris 2026-06-12 10:44:05 -04:00
parent 5e6b201336
commit 01cad11472
3 changed files with 9 additions and 7 deletions

View File

@ -141,13 +141,15 @@
return;
}
const altchaWidget = form.querySelector('altcha-widget');
const altchaValue = altchaWidget ? altchaWidget.value : '';
const errAltcha = document.getElementById('err-altcha');
if (errAltcha) errAltcha.style.display = 'none';
const altchaInput = form.querySelector('[name="altcha"]');
const altchaValue = altchaInput?.value || '';
if (!altchaValue) {
const errEl = document.getElementById('err-altcha');
if (errEl) { errEl.style.display = ''; }
if (errAltcha) errAltcha.style.display = '';
showAlert('Please complete the verification.', 'is-warning');
altchaWidget && altchaWidget.scrollIntoView({ behavior: 'smooth', block: 'center' });
form.querySelector('altcha-widget')?.scrollIntoView({ behavior: 'smooth', block: 'center' });
return;
}

View File

@ -145,7 +145,7 @@
<div class="field">
<altcha-widget
challengeurl="/api/altcha"
challenge="/api/altcha"
style="--altcha-color-border: #dbdbdb; --altcha-border-radius: 4px; --altcha-color-text: #363636;"
></altcha-widget>
<p class="help is-danger" id="err-altcha" style="display:none;">Please complete the verification.</p>

View File

@ -220,7 +220,7 @@
<div class="field">
<altcha-widget
challengeurl="/api/altcha"
challenge="/api/altcha"
style="--altcha-color-border: #dbdbdb; --altcha-border-radius: 4px; --altcha-color-text: #363636;"
></altcha-widget>
<p class="help is-danger" id="err-altcha" style="display:none;">Please complete the verification.</p>