SharkyKZ / joomla-turnstile-plugin

Cloudflare Turnstile anti-spam plugin for Joomla!
GNU General Public License v3.0
12 stars 1 forks source link

Get $code value in triggerEvent() from request #6

Closed Globulopolis closed 1 month ago

Globulopolis commented 1 month ago

Hi! Code:

try
{
    $app->triggerEvent('onCheckAnswer');
}
catch (Exception $e)
{
    ...
}

will always return error. Because an empty $code value provided.

So we need to add value like this

$app->triggerEvent('onCheckAnswer', array($app->input->getCmd('turnstile')));

in component or just add a fallback, before https://github.com/SharkyKZ/joomla-turnstile-plugin/blob/master/code/plugins/captcha/turnstile/turnstile.php#L218

$code = $code ?? $input->getCmd('turnstile');

SharkyKZ commented 1 month ago

This is not a valid way to use Captcha. Captcha plugins were never meant to use plugin events. They must be triggered through Joomla\CMS\Captcha\Captcha class.