Skip to content
This repository has been archived by the owner on Mar 12, 2019. It is now read-only.

Commit

Permalink
Invisible reCaptcha management
Browse files Browse the repository at this point in the history
  • Loading branch information
phoenix128 committed Aug 22, 2017
1 parent 44f5a0c commit 5cfdc05
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 27 deletions.
18 changes: 18 additions & 0 deletions Block/Adminhtml/ReCaptcha.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,24 @@ public function getPublicKey()
return $this->config->getPublicKey();
}

/**
* Get backend theme
* @return string
*/
public function getTheme()
{
return $this->config->getBackendTheme();
}

/**
* Get backend size
* @return string
*/
public function getSize()
{
return $this->config->getBackendSize();
}

/**
* Return true if can display reCaptcha
* @return bool
Expand Down
18 changes: 0 additions & 18 deletions Model/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ class Config
const XML_PATH_ENABLED_BACKEND = 'msp_securitysuite_recaptcha/backend/enabled';
const XML_PATH_ENABLED_FRONTEND = 'msp_securitysuite_recaptcha/frontend/enabled';

const XML_PATH_TYPE_BACKEND = 'msp_securitysuite_recaptcha/backend/type';
const XML_PATH_TYPE_FRONTEND = 'msp_securitysuite_recaptcha/frontend/type';

const XML_PATH_POSITION_FRONTEND = 'msp_securitysuite_recaptcha/frontend/position';
Expand Down Expand Up @@ -180,10 +179,6 @@ public function getFrontendSize()
*/
public function getBackendSize()
{
if ($this->getBackendType() == Type::TYPE_INVISIBLE) {
return 'invisible';
}

return $this->scopeConfig->getValue(static::XML_PATH_SIZE_BACKEND);
}

Expand All @@ -206,10 +201,6 @@ public function getFrontendTheme()
*/
public function getBackendTheme()
{
if ($this->getBackendType() == Type::TYPE_INVISIBLE) {
return null;
}

return $this->scopeConfig->getValue(static::XML_PATH_THEME_BACKEND);
}

Expand All @@ -234,13 +225,4 @@ public function getFrontendType()
{
return $this->scopeConfig->getValue(static::XML_PATH_TYPE_FRONTEND);
}

/**
* Get data size
* @return string
*/
public function getBackendType()
{
return $this->scopeConfig->getValue(static::XML_PATH_TYPE_BACKEND);
}
}
7 changes: 0 additions & 7 deletions etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,6 @@
<label>Enable</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
</field>
<field id="type" translate="label" type="select" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="0" canRestore="1">
<label>reCaptcha type</label>
<source_model>MSP\ReCaptcha\Model\Config\Source\Type</source_model>
<depends>
<field id="enabled">1</field>
</depends>
</field>
<field id="theme" translate="label" type="select" sortOrder="50" showInDefault="1" showInWebsite="0" showInStore="0" canRestore="1">
<label>Theme</label>
<source_model>MSP\ReCaptcha\Model\Config\Source\Theme</source_model>
Expand Down
1 change: 0 additions & 1 deletion etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
<backend>
<enabled>0</enabled>
<size>normal</size>
<type>standard</type>
<theme>light</theme>
</backend>
<frontend>
Expand Down
6 changes: 5 additions & 1 deletion view/adminhtml/templates/msp_recaptcha.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
?>
<?php if ($block->canDisplayCaptcha()): ?>
<div class="admin__field field-recaptcha">
<div class="g-recaptcha" data-sitekey="<?php echo $block->getPublicKey() ?>"></div>
<div class="g-recaptcha"
data-sitekey="<?php echo $block->getPublicKey() ?>"
data-size="<?php echo $block->getSize() ?>"
data-theme="<?php echo $block->getTheme() ?>"
></div>
</div>
<?php endif; ?>
1 change: 1 addition & 0 deletions view/frontend/layout/default.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
<item name="configSource" xsi:type="string">checkoutConfig</item>
<item name="reCaptchaId" xsi:type="string">msp-recaptcha-popup-login</item>
<item name="zone" xsi:type="string">login</item>
<item name="badge" xsi:type="string">inline</item>
</item>
</item>
</item>
Expand Down
1 change: 1 addition & 0 deletions view/frontend/web/js/reCaptcha.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ define(

// Move our (last) handler topmost. We need this to avoid submit bindings with ko.
var listeners = $._data($parentForm[0], 'events').submit;
debugger;
listeners.unshift(listeners.pop());

// Create a virtual token field
Expand Down

0 comments on commit 5cfdc05

Please sign in to comment.