Skip to content

[SMTNC-228] Add captcha token regeneration after form submission#974

Open
larodiel wants to merge 13 commits into
release/M26.gardevoirfrom
fix/KAD-5541-re-captcha-fail-after-the-first-successful-submission
Open

[SMTNC-228] Add captcha token regeneration after form submission#974
larodiel wants to merge 13 commits into
release/M26.gardevoirfrom
fix/KAD-5541-re-captcha-fail-after-the-first-successful-submission

Conversation

@larodiel
Copy link
Copy Markdown

@larodiel larodiel commented Apr 22, 2026

🎫 Ticket

KAD-5541
SMTNC-228

🎥 Artifacts

Before Fix

Screen.Recording.2026-04-22.at.16.47.11.mov

After Fix

Screen.Recording.2026-04-22.at.16.45.27.mov

🗒️ Description

Users were unable to submit forms multiple times when using reCAPTCHA v3, Turnstile, or hCaptcha. The first submission worked, but subsequent attempts failed with a captcha error.

Added regenerateCaptchaTokens() function that:

  • Regenerates Google reCAPTCHA v3 tokens after form submission
  • Resets Turnstile and hCaptcha widgets to generate new tokens
  • Called automatically after successful form submission

✔️ Checklist

  • I have performed a self-review.
  • No unrelated files are modified.
  • No debugging statements exist (Ex: console.log, error_log).
  • There are no warnings or notices in the wordpress error log.
  • Passes all tests (linting, acceptance, & unit)

Block specific checklist (where relevant)

  • Tested with an existing instance of this block .
  • Tested creating a new instance of this block.
  • Tested with Dynamic content & Elements.

Implemented a new function to regenerate captcha tokens for Google reCAPTCHA v3, Cloudflare Turnstile, and hCaptcha after form submissions. This ensures users can submit the form multiple times without encountering token issues. Updated the form handling logic to call this function upon successful form reset.
@larodiel larodiel self-assigned this Apr 22, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 22, 2026

🎉 Zip build complete

Build timestamp

@larodiel larodiel changed the base branch from master to release/M26.gardevoir April 22, 2026 20:00
@gilbert-hernandez gilbert-hernandez self-requested a review April 23, 2026 02:48
Comment thread includes/assets/js/kb-header-block.min.js
Comment thread src/assets/js/kb-advanced-form-block.js Outdated
Comment thread src/assets/js/kb-advanced-form-block.js Outdated
…eader functionality and improve mobile breakpoint handling. Added methods for managing header height and responsive behavior based on viewport size.
…in the captcha block. Update JavaScript to retrieve the site key from the data attribute for token regeneration, improving the handling of reCAPTCHA v3 tokens during form submissions.
Copy link
Copy Markdown
Contributor

@gilbert-hernandez gilbert-hernandez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Thanks!

gilbert-hernandez and others added 9 commits April 23, 2026 09:11
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@kadence/* packages ship source only (dist/ is gitignored). bun skips
prepare scripts for git dependencies, so dist/ is missing after install.
Add an explicit npm install + build step matching the eslint workflow.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
bun migrates package-lock.json entries as git-clone URLs, which fails
in CI. Without --frozen-lockfile, bun resolves github: shorthands via
tarball download instead, which works without SSH or git credentials.
No bun.lockb is committed yet so --frozen-lockfile provided no
reproducibility benefit anyway.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ge resolution

Bun migrates from package-lock.json when no bun.lockb exists, using
git+https:// resolved URLs that require git-cloning the @kadence/* repos.
Deleting the npm lockfile forces bun to use package.json's github: shorthands,
which it fetches via tarball API instead — no git-clone, no auth required.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The @kadence/* packages reference each other via ssh:// URLs in their
own package.json files. GitHub Actions has no SSH key, so npm install
fails with a publickey error. Rewriting ssh://git@github.com/ and
git@github.com: to https://github.com/ allows public repo clones
without auth.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… builds

git config --global writes to ~/.gitconfig but npm's spawned git subprocess
doesn't reliably inherit it. Setting GIT_CONFIG_GLOBAL to an explicit temp
file guarantees all git processes in the step (including npm's internal calls)
use the SSH-to-HTTPS URL rewrite.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@kadence/helpers declares @kadence/icons as a git+https dependency,
causing npm install to hit GitHub on every CI job. --omit=prod skips
production deps entirely and only installs the devDependencies (babel)
needed to build. Babel transpiles syntax only and does not resolve
imports, so the missing runtime dep does not affect the build output.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@gilbert-hernandez
Copy link
Copy Markdown
Contributor

@ravinderk
I made some changes to the workflow tests. The tests fail in the release/M26.gardevoir branch but they're now fixed in this KAD-5541 branch.

@larodiel larodiel changed the title [KAD-5541] Add captcha token regeneration after form submission [SMTNC-228] Add captcha token regeneration after form submission May 15, 2026
@linear
Copy link
Copy Markdown

linear Bot commented May 15, 2026

SMTNC-228

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants