Skip to content

Commit f5ff14c

Browse files
committed
add recaptcha api url setting
1 parent 3f3b0b3 commit f5ff14c

File tree

79 files changed

+404
-390
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+404
-390
lines changed

ReCaptchaAdminUi/Model/CaptchaTypeResolver.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,6 @@ public function __construct(
3636
*/
3737
public function getCaptchaTypeFor(string $key): ?string
3838
{
39-
$type = $this->scopeConfig->getValue(
40-
self::XML_PATH_TYPE_FOR . $key
41-
);
42-
return $type;
39+
return $this->scopeConfig->getValue(self::XML_PATH_TYPE_FOR . $key);
4340
}
4441
}

ReCaptchaAdminUi/Model/ErrorMessageConfig.php

+2-8
Original file line numberDiff line numberDiff line change
@@ -38,20 +38,14 @@ public function __construct(
3838
*/
3939
public function getTechnicalFailureMessage(): string
4040
{
41-
return $this->scopeConfig->getValue(
42-
self::XML_PATH_TECHNICAL,
43-
ScopeInterface::SCOPE_STORE
44-
);
41+
return (string)$this->scopeConfig->getValue(self::XML_PATH_TECHNICAL, ScopeInterface::SCOPE_STORE);
4542
}
4643

4744
/**
4845
* @inheritdoc
4946
*/
5047
public function getValidationFailureMessage(): string
5148
{
52-
return $this->scopeConfig->getValue(
53-
self::XML_PATH_VALIDATION,
54-
ScopeInterface::SCOPE_STORE
55-
);
49+
return (string)$this->scopeConfig->getValue(self::XML_PATH_VALIDATION, ScopeInterface::SCOPE_STORE);
5650
}
5751
}

ReCaptchaAdminUi/Model/OptionSource.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
namespace Magento\ReCaptchaAdminUi\Model;
99

1010
use Magento\Framework\Data\OptionSourceInterface;
11+
use function array_values;
1112

1213
/**
1314
* Generic class for reCAPTCHA Stores/System Configuration options
@@ -29,14 +30,14 @@ class OptionSource implements OptionSourceInterface
2930
*/
3031
public function __construct(array $options = [])
3132
{
32-
$this->options = $options;
33+
$this->options = array_values($options);
3334
}
3435

3536
/**
36-
* @inheritDoc
37+
* @inheritdoc
3738
*/
3839
public function toOptionArray(): array
3940
{
40-
return array_values($this->options);
41+
return $this->options;
4142
}
4243
}

ReCaptchaAdminUi/etc/adminhtml/system.xml

+22-19
Original file line numberDiff line numberDiff line change
@@ -5,57 +5,60 @@
55
* See COPYING.txt for license details.
66
*/
77
-->
8-
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9-
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
8+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
109
<system>
1110
<tab id="security" translate="label" sortOrder="200">
1211
<label>Security</label>
1312
</tab>
1413

15-
<section id="recaptcha_backend" translate="label" type="text" sortOrder="600" showInDefault="1"
16-
showInWebsite="0" showInStore="0">
14+
<section id="recaptcha" translate="label" showInDefault="1" showInWebsite="1" showInStore="1" sortOrder="600">
1715
<class>separator-top</class>
18-
<label>Google reCAPTCHA Admin Panel</label>
16+
<label>Google reCAPTCHA</label>
1917
<tab>security</tab>
2018
<resource>Magento_ReCaptchaUi::config</resource>
19+
<group id="api" translate="label" showInDefault="1" showInWebsite="1" showInStore="1" sortOrder="10">
20+
<label>API</label>
21+
<field id="url" type="select" translate="label" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
22+
<label>API URL</label>
23+
<source_model>Magento\ReCaptchaAdminUi\Model\OptionSource\ApiUrl</source_model>
24+
</field>
25+
</group>
26+
</section>
2127

22-
<group id="type_for" translate="label" type="text" sortOrder="1000" showInDefault="1" showInWebsite="0"
28+
<section id="recaptcha_backend" translate="label" sortOrder="600" showInDefault="1" showInWebsite="0" showInStore="0">
29+
<class>separator-top</class>
30+
<label>Google reCAPTCHA Admin Panel</label>
31+
<tab>security</tab>
32+
<resource>Magento_ReCaptchaUi::config</resource>
33+
<group id="type_for" translate="label" sortOrder="1000" showInDefault="1" showInWebsite="0"
2334
showInStore="0">
2435
<label>Admin Panel</label>
25-
<field id="recaptcha_backend_info_heading" translate="label" sortOrder="100" showInDefault="1"
26-
showInWebsite="0" showInStore="0" >
36+
<field id="recaptcha_backend_info_heading" translate="label" sortOrder="100" showInDefault="1" showInWebsite="0" showInStore="0" >
2737
<frontend_model>Magento\ReCaptchaAdminUi\Block\Adminhtml\System\Config\Form\Field\Notice</frontend_model>
2838
</field>
2939
</group>
3040

31-
<group id="failure_messages" translate="label" type="text" sortOrder="950" showInDefault="1" showInWebsite="1"
32-
showInStore="1">
41+
<group id="failure_messages" translate="label" sortOrder="950" showInDefault="1" showInWebsite="1" showInStore="1">
3342
<label>reCAPTCHA Failure Messages</label>
34-
3543
<field id="validation_failure_message" translate="label" type="textarea" sortOrder="10" showInDefault="1"
3644
showInWebsite="0" showInStore="0" canRestore="1">
3745
<label>reCAPTCHA Validation Failure Message</label>
3846
</field>
39-
4047
<field id="technical_failure_message" translate="label" type="textarea" sortOrder="20" showInDefault="1"
4148
showInWebsite="0" showInStore="0" canRestore="1">
4249
<label>reCAPTCHA Technical Failure Message</label>
4350
</field>
4451
</group>
4552
</section>
4653

47-
<section id="recaptcha_frontend" translate="label" type="text" sortOrder="700" showInDefault="1"
48-
showInWebsite="1" showInStore="1">
54+
<section id="recaptcha_frontend" translate="label" showInDefault="1" showInWebsite="1" showInStore="1" sortOrder="700">
4955
<class>separator-top</class>
5056
<label>Google reCAPTCHA Storefront</label>
5157
<tab>security</tab>
5258
<resource>Magento_ReCaptchaUi::config</resource>
53-
54-
<group id="type_for" translate="label" type="text" sortOrder="1000" showInDefault="1" showInWebsite="1"
55-
showInStore="0">
59+
<group id="type_for" translate="label" showInDefault="1" showInWebsite="1" showInStore="0" sortOrder="1000">
5660
<label>Storefront</label>
57-
<field id="recaptcha_frontend_info_heading" translate="label" sortOrder="100" showInDefault="1"
58-
showInWebsite="1" showInStore="0">
61+
<field id="recaptcha_frontend_info_heading" translate="label" sortOrder="100" showInDefault="1" showInWebsite="1" showInStore="0">
5962
<frontend_model>Magento\ReCaptchaAdminUi\Block\Adminhtml\System\Config\Form\Field\Notice</frontend_model>
6063
</field>
6164
</group>

ReCaptchaAdminUi/etc/di.xml

+16-4
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@
55
* See COPYING.txt for license details.
66
*/
77
-->
8-
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9-
xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
10-
<virtualType name="Magento\ReCaptchaAdminUi\Model\OptionSource\Type"
11-
type="Magento\ReCaptchaAdminUi\Model\OptionSource">
8+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
9+
<virtualType name="Magento\ReCaptchaAdminUi\Model\OptionSource\Type" type="Magento\ReCaptchaAdminUi\Model\OptionSource">
1210
<arguments>
1311
<argument name="options" xsi:type="array">
1412
<item name="default" xsi:type="array">
@@ -18,4 +16,18 @@
1816
</argument>
1917
</arguments>
2018
</virtualType>
19+
<virtualType name="Magento\ReCaptchaAdminUi\Model\OptionSource\ApiUrl" type="Magento\ReCaptchaAdminUi\Model\OptionSource">
20+
<arguments>
21+
<argument name="options" xsi:type="array">
22+
<item name="default" xsi:type="array">
23+
<item name="label" xsi:type="string" translate="true">www.google.com</item>
24+
<item name="value" xsi:type="string">https://www.google.com/recaptcha/api.js</item>
25+
</item>
26+
<item name="global" xsi:type="array">
27+
<item name="label" xsi:type="string" translate="true">www.recaptcha.net</item>
28+
<item name="value" xsi:type="string">https://www.recaptcha.net/recaptcha/api.js</item>
29+
</item>
30+
</argument>
31+
</arguments>
32+
</virtualType>
2133
</config>

ReCaptchaAdminUi/etc/module.xml

+8-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@
55
* See COPYING.txt for license details.
66
*/
77
-->
8-
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9-
xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
10-
<module name="Magento_ReCaptchaAdminUi"/>
8+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
9+
<module name="Magento_ReCaptchaAdminUi">
10+
<sequence>
11+
<module name="Magento_Config"/>
12+
<module name="Magento_ReCaptchaUi"/>
13+
<module name="Magento_Store"/>
14+
</sequence>
15+
</module>
1116
</config>

ReCaptchaAdminUi/registration.php

+3-5
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
*/
66
declare(strict_types=1);
77

8-
\Magento\Framework\Component\ComponentRegistrar::register(
9-
\Magento\Framework\Component\ComponentRegistrar::MODULE,
10-
'Magento_ReCaptchaAdminUi',
11-
__DIR__
12-
);
8+
use Magento\Framework\Component\ComponentRegistrar;
9+
10+
ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Magento_ReCaptchaAdminUi', __DIR__);

ReCaptchaCheckout/Block/LayoutProcessor/Checkout/Onepage.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function __construct(
4646
* @return array
4747
* @throws InputException
4848
*/
49-
public function process($jsLayout)
49+
public function process($jsLayout): array
5050
{
5151
$key = 'customer_login';
5252
if ($this->isCaptchaEnabled->isCaptchaEnabledFor($key)) {
@@ -76,6 +76,7 @@ public function process($jsLayout)
7676
unset($jsLayout['components']['checkout']['children']['authentication']['children']['recaptcha']);
7777
}
7878
}
79+
7980
return $jsLayout;
8081
}
8182
}

ReCaptchaCheckout/etc/module.xml

+7-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@
55
* See COPYING.txt for license details.
66
*/
77
-->
8-
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9-
xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
10-
<module name="Magento_ReCaptchaCheckout"/>
8+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
9+
<module name="Magento_ReCaptchaCheckout">
10+
<sequence>
11+
<module name="Magento_Checkout"/>
12+
<module name="Magento_ReCaptchaUi"/>
13+
</sequence>
14+
</module>
1115
</config>

ReCaptchaCheckout/registration.php

+3-5
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
*/
66
declare(strict_types=1);
77

8-
\Magento\Framework\Component\ComponentRegistrar::register(
9-
\Magento\Framework\Component\ComponentRegistrar::MODULE,
10-
'Magento_ReCaptchaCheckout',
11-
__DIR__
12-
);
8+
use Magento\Framework\Component\ComponentRegistrar;
9+
10+
ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Magento_ReCaptchaCheckout', __DIR__);

ReCaptchaCheckout/view/frontend/layout/checkout_index_index.xml

+1-4
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55
* See COPYING.txt for license details.
66
*/
77
-->
8-
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9-
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
10-
8+
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
119
<body>
1210
<referenceBlock name="checkout.root">
1311
<arguments>
@@ -55,7 +53,6 @@
5553
</item>
5654
</item>
5755
</item>
58-
5956
<item name="authentication" xsi:type="array">
6057
<item name="children" xsi:type="array">
6158
<item name="recaptcha" xsi:type="array">

ReCaptchaContact/etc/module.xml

+6-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
* See COPYING.txt for license details.
66
*/
77
-->
8-
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9-
xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
10-
<module name="Magento_ReCaptchaContact"/>
8+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
9+
<module name="Magento_ReCaptchaContact">
10+
<sequence>
11+
<module name="Magento_ReCaptchaUi"/>
12+
</sequence>
13+
</module>
1114
</config>

ReCaptchaContact/registration.php

+3-5
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
*/
66
declare(strict_types=1);
77

8-
\Magento\Framework\Component\ComponentRegistrar::register(
9-
\Magento\Framework\Component\ComponentRegistrar::MODULE,
10-
'Magento_ReCaptchaContact',
11-
__DIR__
12-
);
8+
use Magento\Framework\Component\ComponentRegistrar;
9+
10+
ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Magento_ReCaptchaContact', __DIR__);

ReCaptchaContact/view/frontend/layout/contact_index_index.xml

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
* See COPYING.txt for license details.
66
*/
77
-->
8-
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9-
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
8+
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
109
<body>
1110
<referenceContainer name="form.additional.info">
1211
<block class="Magento\ReCaptchaUi\Block\ReCaptcha"

ReCaptchaCustomer/etc/module.xml

+8-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@
55
* See COPYING.txt for license details.
66
*/
77
-->
8-
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9-
xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
10-
<module name="Magento_ReCaptchaCustomer"/>
8+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
9+
<module name="Magento_ReCaptchaCustomer">
10+
<sequence>
11+
<module name="Magento_Customer"/>
12+
<module name="Magento_ReCaptchaUi"/>
13+
<module name="Magento_ReCaptchaValidationApi"/>
14+
</sequence>
15+
</module>
1116
</config>

ReCaptchaFrontendUi/Model/CaptchaTypeResolver.php

+1-5
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,6 @@ public function __construct(
3737
*/
3838
public function getCaptchaTypeFor(string $key): ?string
3939
{
40-
$type = $this->scopeConfig->getValue(
41-
self::XML_PATH_TYPE_FOR . $key,
42-
ScopeInterface::SCOPE_WEBSITE
43-
);
44-
return $type;
40+
return $this->scopeConfig->getValue(self::XML_PATH_TYPE_FOR . $key, ScopeInterface::SCOPE_WEBSITE);
4541
}
4642
}

ReCaptchaFrontendUi/Model/ErrorMessageConfig.php

+2-8
Original file line numberDiff line numberDiff line change
@@ -38,20 +38,14 @@ public function __construct(
3838
*/
3939
public function getTechnicalFailureMessage(): string
4040
{
41-
return $this->scopeConfig->getValue(
42-
self::XML_PATH_TECHNICAL,
43-
ScopeInterface::SCOPE_STORE
44-
);
41+
return $this->scopeConfig->getValue(self::XML_PATH_TECHNICAL, ScopeInterface::SCOPE_STORE);
4542
}
4643

4744
/**
4845
* @inheritdoc
4946
*/
5047
public function getValidationFailureMessage(): string
5148
{
52-
return $this->scopeConfig->getValue(
53-
self::XML_PATH_VALIDATION,
54-
ScopeInterface::SCOPE_STORE
55-
);
49+
return $this->scopeConfig->getValue(self::XML_PATH_VALIDATION, ScopeInterface::SCOPE_STORE);
5650
}
5751
}

ReCaptchaFrontendUi/Plugin/ExcludeFromMinification.php

-34
This file was deleted.

ReCaptchaFrontendUi/etc/frontend/di.xml

-4
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,4 @@
1111
type="Magento\ReCaptchaFrontendUi\Model\CaptchaTypeResolver"/>
1212
<preference for="Magento\ReCaptchaUi\Model\ErrorMessageConfigInterface"
1313
type="Magento\ReCaptchaFrontendUi\Model\ErrorMessageConfig"/>
14-
<type name="Magento\Framework\View\Asset\Minification">
15-
<plugin name="exclude-recaptcha-from-minification"
16-
type="Magento\ReCaptchaFrontendUi\Plugin\ExcludeFromMinification"/>
17-
</type>
1814
</config>

0 commit comments

Comments
 (0)