From 6b85112a9be4bc381bc21bbf425e8d214f50d71e Mon Sep 17 00:00:00 2001 From: arthas78 Date: Mon, 4 May 2020 16:55:42 +0700 Subject: [PATCH 1/4] fix bug --- Observer/Captcha.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Observer/Captcha.php b/Observer/Captcha.php index e20fe82..691391f 100644 --- a/Observer/Captcha.php +++ b/Observer/Captcha.php @@ -128,7 +128,7 @@ public function execute(Observer $observer) return $this->redirectUrlError(__('Missing required parameters recaptcha!')); } } - if ($captcha !== null) { + if ($captcha !== '') { $type = $this->_helperData->getRecaptchaType(); $response = $this->_helperData->verifyResponse($type); if (isset($response['success']) && !$response['success']) { From 46cf1dd870e8049c020b7c7676a04b05bffca2a1 Mon Sep 17 00:00:00 2001 From: arthas78 Date: Mon, 4 May 2020 17:14:04 +0700 Subject: [PATCH 2/4] fix bug --- Observer/Captcha.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Observer/Captcha.php b/Observer/Captcha.php index 691391f..333e2b3 100644 --- a/Observer/Captcha.php +++ b/Observer/Captcha.php @@ -120,7 +120,7 @@ public function execute(Observer $observer) $checkResponse = 0; $captcha = $this->_request->getParam('g-recaptcha-response'); // case ajax login - if ($item === 'customer/ajax/login' && $captcha === null && $this->_request->isAjax()) { + if ($item === 'customer/ajax/login' && !empty($captcha) && $this->_request->isAjax()) { $formData = HelperData::jsonDecode($this->requestInterface->getContent()); if (array_key_exists('g-recaptcha-response', $formData)) { $captcha = $formData['g-recaptcha-response']; @@ -128,7 +128,7 @@ public function execute(Observer $observer) return $this->redirectUrlError(__('Missing required parameters recaptcha!')); } } - if ($captcha !== '') { + if (!empty($captcha)) { $type = $this->_helperData->getRecaptchaType(); $response = $this->_helperData->verifyResponse($type); if (isset($response['success']) && !$response['success']) { @@ -140,8 +140,7 @@ public function execute(Observer $observer) } } - if ($checkResponse === 1 && - ($this->_request->getParam('g-recaptcha-response') !== null || $captcha !== false)) { + if ($checkResponse === 1 && $captcha !== false) { $this->redirectUrlError(__('Missing Url in "Form Post Paths" configuration field!')); } } From de7509e70ac97f20555589fb0f647f0cfc54b058 Mon Sep 17 00:00:00 2001 From: arthas78 Date: Wed, 6 May 2020 10:38:45 +0700 Subject: [PATCH 3/4] fix bug check condition catpcha --- Helper/Data.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Helper/Data.php b/Helper/Data.php index 44429f5..64f6a81 100644 --- a/Helper/Data.php +++ b/Helper/Data.php @@ -306,8 +306,9 @@ public function getLanguageCode($storeId = null) */ public function verifyResponse($end = null, $recaptcha = null) { + $result['success'] = false; $recaptcha = $recaptcha ?: $this->_request->getParam('g-recaptcha-response'); - if (!$recaptcha) { + if (empty($recaptcha)) { $result['message'] = __('The response parameter is missing.'); return $result; From 4e00bddaaec865c513676451eee5fb8770923e7c Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 6 May 2020 16:12:18 +0700 Subject: [PATCH 4/4] Clean code --- Helper/Data.php | 2 +- composer.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Helper/Data.php b/Helper/Data.php index 64f6a81..733c675 100644 --- a/Helper/Data.php +++ b/Helper/Data.php @@ -307,7 +307,7 @@ public function getLanguageCode($storeId = null) public function verifyResponse($end = null, $recaptcha = null) { $result['success'] = false; - $recaptcha = $recaptcha ?: $this->_request->getParam('g-recaptcha-response'); + $recaptcha = $recaptcha ?: $this->_request->getParam('g-recaptcha-response'); if (empty($recaptcha)) { $result['message'] = __('The response parameter is missing.'); diff --git a/composer.json b/composer.json index aad1f34..0646530 100644 --- a/composer.json +++ b/composer.json @@ -6,7 +6,7 @@ "google/recaptcha": "^1.2" }, "type": "magento2-module", - "version": "1.2.0", + "version": "1.2.1", "license": "proprietary", "authors": [ {