From 20de029c45f77b231efe3a72f03525e50686d95a Mon Sep 17 00:00:00 2001 From: Tobi Date: Thu, 1 Nov 2018 10:51:10 +0100 Subject: [PATCH] Prevent producing an error if http-request is failing --- .../community/NoGlitchYo/GoogleRecaptcha/Model/Validator.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/code/community/NoGlitchYo/GoogleRecaptcha/Model/Validator.php b/app/code/community/NoGlitchYo/GoogleRecaptcha/Model/Validator.php index a8aceea..0209328 100644 --- a/app/code/community/NoGlitchYo/GoogleRecaptcha/Model/Validator.php +++ b/app/code/community/NoGlitchYo/GoogleRecaptcha/Model/Validator.php @@ -36,6 +36,9 @@ public function validate() try { $data = $this->_request($captchaResponse, $secret); + if (empty($data)) { + return false; + } } catch (Exception $e) { return false; } @@ -68,10 +71,12 @@ protected function _request($captchaResponse, $secret) catch (Zend_Http_Exception $e) { Mage::logException($e); Mage::getSingleton('customer/session')->addError(Mage::helper('grecaptcha')->__('Unable to validate the reCAPTCHA with Google. Please, retry later.')); + return null; } catch (Exception $e) { Mage::logException($e); Mage::getSingleton('customer/session')->addError(Mage::helper('grecaptcha')->__('Unable to validate the reCAPTCHA.')); + return null; } return $this->_parseResponse($response);