Skip to content

Commit

Permalink
Merge pull request #50 from mageplaza/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
haitv282 committed May 6, 2020
2 parents 4aac419 + 4e00bdd commit 5458ff1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
5 changes: 3 additions & 2 deletions Helper/Data.php
Expand Up @@ -306,8 +306,9 @@ public function getLanguageCode($storeId = null)
*/
public function verifyResponse($end = null, $recaptcha = null)
{
$recaptcha = $recaptcha ?: $this->_request->getParam('g-recaptcha-response');
if (!$recaptcha) {
$result['success'] = false;
$recaptcha = $recaptcha ?: $this->_request->getParam('g-recaptcha-response');
if (empty($recaptcha)) {
$result['message'] = __('The response parameter is missing.');

return $result;
Expand Down
7 changes: 3 additions & 4 deletions Observer/Captcha.php
Expand Up @@ -120,15 +120,15 @@ 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'];
} else {
return $this->redirectUrlError(__('Missing required parameters recaptcha!'));
}
}
if ($captcha !== null) {
if (!empty($captcha)) {
$type = $this->_helperData->getRecaptchaType();
$response = $this->_helperData->verifyResponse($type);
if (isset($response['success']) && !$response['success']) {
Expand All @@ -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!'));
}
}
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -6,7 +6,7 @@
"google/recaptcha": "^1.2"
},
"type": "magento2-module",
"version": "1.2.0",
"version": "1.2.1",
"license": "proprietary",
"authors": [
{
Expand Down

0 comments on commit 5458ff1

Please sign in to comment.