MTCaptcha triggers on every page with multistep forms

Created on 8 March 2023, over 1 year ago

Problem/Motivation

When using MTCaptcha on multistep forms, it will display on every step. But when filled in correctly, you don't want to display it on other steps.

Steps to reproduce

Create multistep form with webform module and add mtcaptca to it. You will see the mtcaptcha form on multiple steps, even after filling one in correctly.

Proposed resolution

Use the 'checktoken' api to check if the token is still valid. I don't know how long a token is valid, but they say a few minutes. This is enough to fill in a form I think. See the spec for the api:

CHECKTOKEN API 
  URL: https://service.mtcaptcha.com/mtcv1/api/checktoken
  HTTP METHOD: GET
  Parameters:
    privatekey   : The shared PrivateKey secret between your server and MTCaptcha.  (Required)
   token           : The VerifiedToken string.  (Required)
eg: 
https://service.mtcaptcha.com/mtcv1/api/checktoken?privatekey=<your_privatekey>&token=<verified-token>

This means that we need to save the verified-token for a couple of minutes. Because the mtcaptcha form is rendered through ajax, the verified token in the form always changes on pageloads of ajax refreshes. Therefore saving the token in the temp storage is the only way to prevent multiple mtcaptchas in one form.

🐛 Bug report
Status

Active

Version

6.1

Component

Code

Created by

🇳🇱Netherlands Krilo_89

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024