diff --git a/src/old/application/modules/default/controllers/UserController.php b/src/old/application/modules/default/controllers/UserController.php index 84d3d4300..04085ee69 100755 --- a/src/old/application/modules/default/controllers/UserController.php +++ b/src/old/application/modules/default/controllers/UserController.php @@ -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'])) {