Fix FriendlyCaptcha for Guest Action

This commit is contained in:
Thomas Peterson 2025-10-21 10:47:16 +02:00
parent 3ab566926c
commit fbd0cbf43e

View File

@ -3106,7 +3106,32 @@ class UserController extends TP_Controller_Action
);
if ($this->_request->isPost()) {
if ($form->isValid($formData)) {
$externalValidation = true;
if ($this->shop->getPluginSettings(
module: 'friendlycaptcha',
name: 'secret',
)) {
$externalValidation = false;
$service_url = 'http://web/apps/api/plugin/system/psc/friendlycaptcha/validate';
$ch = curl_init($service_url);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
'shop_uuid' => $this->shop->uid,
'token' => $this->_request->getParam('frc-captcha-solution'),
]));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
));
$curl_response = curl_exec($ch);
$decoded = json_decode($curl_response, true);
if ($decoded['success'] == true) {
$externalValidation = true;
}
}
if (($this->_getParam('externalValidation', false) || $externalValidation) && $form->isValid($formData)) {
$contact = new Contact();
$contact->self_email = $formData['rech']['self_email'];
if (isset($formData['rech']['self_anrede'])) {