VirtueMart Forum

VirtueMart 2 + 3 + 4 => General Questions => Topic started by: n3t on July 12, 2022, 21:52:40 PM

Title: Invalid Captcha check
Post by: n3t on July 12, 2022, 21:52:40 PM
Hi,

I found issue with Virtuemart 3 and 4. In shopFunctionsF->checkCaptcha is called globally even onCheckAnswer, so it is distributed to all published Captcha plugins, instead of to distribute it just to the one active (selected in global configuration).
Correct way how to call this should be according to Joomla standard, same way as is called in Joomla\CMS\Form\Rule\CaptchaRule, so something like

$app    = \JFactory::getApplication();
$plugin = $app->get('captcha');

if ($app->isClient('site'))
{
$plugin = $app->getParams()->get('captcha', $plugin);
}

// Use 0 for none
if ($plugin === 0 || $plugin === '0')
{
return true;
}

try
{
$captcha = Captcha::getInstance((string) $plugin);
return $captcha->checkAnswer($value);
}
catch (\RuntimeException $e)
{
\JFactory::getApplication()->enqueueMessage($e->getMessage(), 'error');
}
return false;


Currently calling

vDispatcher::trigger('onCheckAnswer',array($recaptcha));

causes all published to run onCheckAnswer event, which could lead in invalid results.

In my case, I use n3t Multi Captcha (https://extensions.joomla.org/extension/access-a-security/site-security/n3t-multi-captcha/) plugin, which, internally, calls ReCaptcha plugin. Virtuemrat causes, that n3t Multi Captcha plugin is checked first, returning TRUE as expected, but next checks ReCaptcha plugin, which causes diuplicate check and ends in exception.
Title: Re: Invalid Captcha check
Post by: pinochico on July 12, 2022, 23:54:19 PM
yes,

thanks Pavel,

therefore, when we prepare to use captcha in VM, we don't use standard VM setup, but we hack and set the call for a specific enabled captcha and not for all installed/enabled captcha plugins.
Maybe when the VM switches to Joomla standards and doesn't try to redo everything to their VM functions or write them correctly, there will be less hacks like this?