Skip to content

Commit

Permalink
Merge pull request #57 from mageplaza/2.4-develop
Browse files Browse the repository at this point in the history
2.4 develop
  • Loading branch information
haitv282 committed Oct 1, 2020
2 parents 69ce69d + a071496 commit 079fc36
Show file tree
Hide file tree
Showing 13 changed files with 207 additions and 206 deletions.
8 changes: 4 additions & 4 deletions Block/Captcha.php
Expand Up @@ -80,7 +80,7 @@ public function __construct(
ThemeProviderInterface $themeProvider,
array $data = []
) {
$this->_helperData = $helperData;
$this->_helperData = $helperData;
$this->_themeProvider = $themeProvider;

parent::__construct($context, $data);
Expand All @@ -91,14 +91,14 @@ public function __construct(
*/
public function getForms()
{
$useLogin = false;
$useLogin = false;
$this->_dataFormId = $this->_helperData->getFormsFrontend();

foreach ($this->_dataFormId as $item => $value) {
switch ($value) {
case Forms::TYPE_LOGIN:
$actionName = $this->actionName[0];
$useLogin = true;
$useLogin = true;
break;
case Forms::TYPE_CREATE:
$actionName = $this->actionName[1];
Expand All @@ -112,7 +112,7 @@ public function getForms()
case Forms::TYPE_PRODUCTREVIEW:
$actionName = $this->actionName[4];
break;
case Forms::TYPE_CHANGEPASSWORD:
case Forms::TYPE_EDITACCOUNT:
$actionName = $this->actionName[5];
break;
default:
Expand Down
2 changes: 1 addition & 1 deletion Console/Adminhtml/Command/Disable.php
Expand Up @@ -55,7 +55,7 @@ public function __construct(
ConfigWriter $configWriter,
$name = null
) {
$this->helperData = $helperData;
$this->helperData = $helperData;
$this->_configWriter = $configWriter;

parent::__construct($name);
Expand Down
2 changes: 1 addition & 1 deletion Console/Adminhtml/Command/Enable.php
Expand Up @@ -55,7 +55,7 @@ public function __construct(
ConfigWriter $configWriter,
$name = null
) {
$this->helperData = $helperData;
$this->helperData = $helperData;
$this->_configWriter = $configWriter;

parent::__construct($name);
Expand Down
12 changes: 6 additions & 6 deletions Helper/Data.php
Expand Up @@ -37,8 +37,8 @@
*/
class Data extends CoreHelper
{
const CONFIG_MODULE_PATH = 'googlerecaptcha';
const BACKEND_CONFIGURATION = '/backend';
const CONFIG_MODULE_PATH = 'googlerecaptcha';
const BACKEND_CONFIGURATION = '/backend';
const FRONTEND_CONFIGURATION = '/frontend';

/**
Expand Down Expand Up @@ -68,7 +68,7 @@ public function __construct(
DefaultFormsPaths $formPaths
) {
$this->_curlFactory = $curlFactory;
$this->_formPaths = $formPaths;
$this->_formPaths = $formPaths;

parent::__construct($context, $objectManager, $storeManager);
}
Expand Down Expand Up @@ -267,7 +267,7 @@ public function getFormPostPaths($storeId = null)
*/
public function getCssSelectors($storeId = null)
{
$data = $this->getConfigFrontend('custom/css', $storeId);
$data = $this->getConfigFrontend('custom/css', $storeId);
$forms = explode("\n", str_replace("\r", '', $data));
foreach ($forms as $key => $value) {
$forms[$key] = trim($value, ' ');
Expand Down Expand Up @@ -307,15 +307,15 @@ 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.');

return $result;
}
try {
$recaptchaClass = new ReCaptcha($end === 'visible' ? $this->getVisibleSecretKey() : $this->getInvisibleSecretKey());
$resp = $recaptchaClass->verify($recaptcha, $this->_request->getClientIp());
$resp = $recaptchaClass->verify($recaptcha, $this->_request->getClientIp());
if ($resp && $resp->isSuccess()) {
$result['success'] = true;
} else {
Expand Down
4 changes: 2 additions & 2 deletions Model/System/Config/Source/Forms.php
Expand Up @@ -29,7 +29,7 @@
*/
class Forms implements ArrayInterface
{
const TYPE_LOGIN = 'backend_login';
const TYPE_LOGIN = 'backend_login';
const TYPE_FORGOT = 'backend_forgotpassword';

/**
Expand All @@ -54,7 +54,7 @@ public function toOptionArray()
public function getOptionHash()
{
return [
self::TYPE_LOGIN => __('Admin Login'),
self::TYPE_LOGIN => __('Admin Login'),
self::TYPE_FORGOT => __('Admin Forgot Password')
];
}
Expand Down
38 changes: 19 additions & 19 deletions Model/System/Config/Source/Frontend/Forms.php
Expand Up @@ -30,14 +30,14 @@
*/
class Forms implements ArrayInterface
{
const TYPE_LOGIN = 'body.customer-account-login #login-form.form.form-login';
const TYPE_CREATE = 'body.customer-account-create #form-validate.form-create-account';
const TYPE_FORGOT = '#form-validate.form.password.forget';
const TYPE_CONTACT = '#contact-form';
const TYPE_CHANGEPASSWORD = '#form-validate.form.form-edit-account';
const TYPE_PRODUCTREVIEW = '#review-form';
const TYPE_LOGIN = 'body.customer-account-login #login-form.form.form-login';
const TYPE_CREATE = 'body.customer-account-create #form-validate.form-create-account';
const TYPE_FORGOT = '#form-validate.form.password.forget';
const TYPE_CONTACT = '#contact-form';
const TYPE_EDITACCOUNT = '#form-validate.form.form-edit-account';
const TYPE_PRODUCTREVIEW = '#review-form';
const TYPE_AGEVERIFICATION = '#mpageverify-form';
const TYPE_FORMSEXTENDED = [
const TYPE_FORMSEXTENDED = [
'.popup-authentication .form.form-login',
'.checkout-index-index form[data-role=login]',
'.onestepcheckout-index-index .form.form-login'
Expand Down Expand Up @@ -80,12 +80,12 @@ public function toOptionArray()
public function getOptionHash()
{
$labels = [
self::TYPE_LOGIN => __('Login'),
self::TYPE_CREATE => __('Create User'),
self::TYPE_FORGOT => __('Forgot Password'),
self::TYPE_CONTACT => __('Contact Us'),
self::TYPE_CHANGEPASSWORD => __('Change Password'),
self::TYPE_PRODUCTREVIEW => __('Product Review')
self::TYPE_LOGIN => __('Login'),
self::TYPE_CREATE => __('Create User'),
self::TYPE_FORGOT => __('Forgot Password'),
self::TYPE_CONTACT => __('Contact Us'),
self::TYPE_EDITACCOUNT => __('Edit Account'),
self::TYPE_PRODUCTREVIEW => __('Product Review')
];
if ($this->checkModuleEnable('Mageplaza_AgeVerification')) {
$labels = array_merge($labels, [self::TYPE_AGEVERIFICATION => __('Age Verification')]);
Expand All @@ -100,12 +100,12 @@ public function getOptionHash()
public function defaultForms()
{
$forms = [
self::TYPE_LOGIN => 'customer/account/loginPost/',
self::TYPE_CREATE => 'customer/account/createpost/',
self::TYPE_FORGOT => 'customer/account/forgotpasswordpost/',
self::TYPE_CONTACT => 'contact/index/post/',
self::TYPE_CHANGEPASSWORD => 'customer/account/editPost/',
self::TYPE_PRODUCTREVIEW => 'review/product/post/'
self::TYPE_LOGIN => 'customer/account/loginPost/',
self::TYPE_CREATE => 'customer/account/createpost/',
self::TYPE_FORGOT => 'customer/account/forgotpasswordpost/',
self::TYPE_CONTACT => 'contact/index/post/',
self::TYPE_EDITACCOUNT => 'customer/account/editPost/',
self::TYPE_PRODUCTREVIEW => 'review/product/post/'
];
if ($this->checkModuleEnable('Mageplaza_AgeVerification')) {
$forms = array_merge($forms, [self::TYPE_AGEVERIFICATION => '']);
Expand Down
10 changes: 5 additions & 5 deletions Observer/Adminhtml/Forgot.php
Expand Up @@ -88,12 +88,12 @@ public function __construct(
ActionFlag $actionFlag,
UrlInterface $urlInterface
) {
$this->_helperData = $helperData;
$this->_request = $httpRequest;
$this->_messageManager = $messageManager;
$this->_helperData = $helperData;
$this->_request = $httpRequest;
$this->_messageManager = $messageManager;
$this->_responseInterface = $responseInterface;
$this->_actionFlag = $actionFlag;
$this->_urlInterface = $urlInterface;
$this->_actionFlag = $actionFlag;
$this->_urlInterface = $urlInterface;
}

/**
Expand Down
20 changes: 10 additions & 10 deletions Observer/Captcha.php
Expand Up @@ -93,13 +93,13 @@ public function __construct(
RedirectInterface $redirect,
RequestInterface $requestInterface
) {
$this->_helperData = $helperData;
$this->_request = $request;
$this->messageManager = $messageManager;
$this->_actionFlag = $actionFlag;
$this->_helperData = $helperData;
$this->_request = $request;
$this->messageManager = $messageManager;
$this->_actionFlag = $actionFlag;
$this->_responseInterface = $responseInterface;
$this->redirect = $redirect;
$this->requestInterface = $requestInterface;
$this->redirect = $redirect;
$this->requestInterface = $requestInterface;
}

/**
Expand All @@ -111,14 +111,14 @@ public function execute(Observer $observer)
{
if ($this->_helperData->isEnabled() && $this->_helperData->isCaptchaFrontend()) {
$checkResponse = 1;
$captcha = false;
$captcha = false;
if ($this->_request->getFullActionName() === 'wishlist_index_add') {
return;
}
foreach ($this->_helperData->getFormPostPaths() as $item) {
if ($item !== '' && strpos($this->_request->getRequestUri(), trim($item, ' ')) !== false) {
$checkResponse = 0;
$captcha = $this->_request->getParam('g-recaptcha-response');
$captcha = $this->_request->getParam('g-recaptcha-response');
// case ajax login
if ($item === 'customer/ajax/login' && !empty($captcha) && $this->_request->isAjax()) {
$formData = HelperData::jsonDecode($this->requestInterface->getContent());
Expand All @@ -129,7 +129,7 @@ public function execute(Observer $observer)
}
}
if (!empty($captcha)) {
$type = $this->_helperData->getRecaptchaType();
$type = $this->_helperData->getRecaptchaType();
$response = $this->_helperData->verifyResponse($type);
if (isset($response['success']) && !$response['success']) {
$this->redirectUrlError($response['message']);
Expand Down Expand Up @@ -157,7 +157,7 @@ public function redirectUrlError($message)
|| strpos($this->_request->getRequestUri(), 'sociallogin/popup/forgot') !== false
) {
return [
'errors' => true,
'errors' => true,
'message' => $message
];
}
Expand Down
54 changes: 27 additions & 27 deletions composer.json
@@ -1,27 +1,27 @@
{
"name": "mageplaza/module-google-recaptcha",
"description": "Magento 2 Google Recaptcha Extension",
"require": {
"mageplaza/module-core": "^1.4.5",
"google/recaptcha": "^1.2"
},
"type": "magento2-module",
"version": "1.2.2",
"license": "proprietary",
"authors": [
{
"name": "Mageplaza",
"email": "support@mageplaza.com",
"homepage": "https://www.mageplaza.com",
"role": "Technical Support "
}
],
"autoload": {
"files": [
"registration.php"
],
"psr-4": {
"Mageplaza\\GoogleRecaptcha\\": ""
}
}
}
{
"name": "mageplaza/module-google-recaptcha",
"description": "Magento 2 Google Recaptcha Extension",
"require": {
"mageplaza/module-core": "^1.4.5",
"google/recaptcha": "^1.2"
},
"type": "magento2-module",
"version": "4.0.0",
"license": "proprietary",
"authors": [
{
"name": "Mageplaza",
"email": "support@mageplaza.com",
"homepage": "https://www.mageplaza.com",
"role": "Technical Support "
}
],
"autoload": {
"files": [
"registration.php"
],
"psr-4": {
"Mageplaza\\GoogleRecaptcha\\": ""
}
}
}

0 comments on commit 079fc36

Please sign in to comment.