File tree Expand file tree Collapse file tree 5 files changed +81
-77
lines changed Expand file tree Collapse file tree 5 files changed +81
-77
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+ /**
3
+ * Copyright 2025 Adobe.
4
+ * All Rights Reserved.
5
+ */
6
+
7
+ declare (strict_types=1 );
8
+ namespace Magento \Captcha \Block ;
9
+
10
+ use Magento \Checkout \Block \Checkout \LayoutProcessorInterface ;
11
+ use Magento \Captcha \Helper \Data as HelperCaptcha ;
12
+
13
+ class CaptchaLayoutProcessor implements LayoutProcessorInterface
14
+ {
15
+ /**
16
+ * @param HelperCaptcha $helper
17
+ */
18
+ public function __construct (
19
+ private readonly HelperCaptcha $ helper
20
+ ) {
21
+ }
22
+
23
+ /**
24
+ * Remove captcha from checkout page if it is disabled
25
+ *
26
+ * @param array $jsLayout
27
+ * @return array
28
+ */
29
+ public function process ($ jsLayout ): array
30
+ {
31
+ if (!$ this ->helper ->getConfig ('enable ' )) {
32
+ if (isset ($ jsLayout ['components ' ]['checkout ' ]['children ' ]['authentication ' ]['children ' ]['captcha ' ])) {
33
+ unset($ jsLayout ['components ' ]['checkout ' ]['children ' ]['authentication ' ]['children ' ]['captcha ' ]);
34
+ }
35
+ if (isset ($ jsLayout ['components ' ]['checkout ' ]['children ' ]['steps ' ]['children ' ]['shipping-step ' ]['children ' ]['shippingAddress ' ]['children ' ]['customer-email ' ]['children ' ]['additional-login-form-fields ' ]['children ' ]['captcha ' ])) {
36
+ unset($ jsLayout ['components ' ]['checkout ' ]['children ' ]['steps ' ]['children ' ]['shipping-step ' ]['children ' ]['shippingAddress ' ]['children ' ]['customer-email ' ]['children ' ]['additional-login-form-fields ' ]['children ' ]['captcha ' ]);
37
+ }
38
+ if (isset ($ jsLayout ['components ' ]['authenticationPopup ' ]['children ' ]['captcha ' ])) {
39
+ unset($ jsLayout ['components ' ]['authenticationPopup ' ]['children ' ]['captcha ' ]);
40
+ }
41
+ }
42
+ return $ jsLayout ;
43
+ }
44
+ }
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 37
37
<type name =" Magento\Sales\Api\OrderManagementInterface" >
38
38
<plugin name =" reset_payment_attempts_after_order_is_placed_plugin" type =" Magento\Captcha\Plugin\ResetPaymentAttemptsAfterOrderIsPlacedPlugin" />
39
39
</type >
40
- <type name =" Magento\Customer\Block\Account\AuthenticationPopup" >
41
- <plugin name =" check_captcha_on_storefront" type =" Magento\Captcha\Plugin\CheckCaptchaOnStorefront" sortOrder =" 10" />
40
+
41
+ <type name =" Magento\Checkout\Block\Onepage" >
42
+ <arguments >
43
+ <argument name =" layoutProcessors" xsi : type =" array" >
44
+ <item name =" captcha_processor" xsi : type =" object" >Magento\Captcha\Block\CaptchaLayoutProcessor</item >
45
+ </argument >
46
+ </arguments >
42
47
</type >
43
48
</config >
Original file line number Diff line number Diff line change 1
1
<?php
2
2
/**
3
- * Copyright © Magento, Inc. All rights reserved .
4
- * See COPYING.txt for license details .
3
+ * Copyright 2015 Adobe .
4
+ * All Rights Reserved .
5
5
*/
6
6
namespace Magento \Customer \Block \Account ;
7
7
8
8
use Magento \Customer \Model \Form ;
9
9
use Magento \Store \Model \ScopeInterface ;
10
+ use Magento \Customer \Model \Context ;
10
11
11
12
/**
12
13
* @api
@@ -48,6 +49,16 @@ public function __construct(
48
49
*/
49
50
public function getJsLayout ()
50
51
{
52
+ // Check if captcha is not enabled and user is not logged in
53
+ if (!$ this ->_scopeConfig ->getValue (
54
+ Form::XML_PATH_CUSTOMER_CAPTCHA_ENABLED ,
55
+ ScopeInterface::SCOPE_STORE
56
+ ) && !$ this ->isLoggedIn ()) {
57
+ if (isset ($ this ->jsLayout ['components ' ]['authenticationPopup ' ]['children ' ]['captcha ' ])) {
58
+ unset($ this ->jsLayout ['components ' ]['authenticationPopup ' ]['children ' ]['captcha ' ]);
59
+ }
60
+ }
61
+
51
62
return $ this ->serializer ->serialize ($ this ->jsLayout );
52
63
}
53
64
@@ -122,4 +133,14 @@ public function getCustomerForgotPasswordUrl()
122
133
{
123
134
return $ this ->getUrl ('customer/account/forgotpassword ' );
124
135
}
136
+
137
+ /**
138
+ * Is logged in
139
+ *
140
+ * @return bool
141
+ */
142
+ private function isLoggedIn (): ?bool
143
+ {
144
+ return $ this ->httpContext ->getValue (Context::CONTEXT_AUTH );
145
+ }
125
146
}
Original file line number Diff line number Diff line change 1
1
<?php
2
2
/**
3
- * Copyright © Magento, Inc. All rights reserved .
4
- * See COPYING.txt for license details .
3
+ * Copyright 2011 Adobe .
4
+ * All Rights Reserved .
5
5
*/
6
6
7
7
namespace Magento \Customer \Model ;
@@ -16,6 +16,11 @@ class Form extends \Magento\Eav\Model\Form
16
16
*/
17
17
public const XML_PATH_ENABLE_AUTOCOMPLETE = 'customer/password/autocomplete_on_storefront ' ;
18
18
19
+ /**
20
+ * XML configuration paths for "Enable CAPTCHA on Storefront" property
21
+ */
22
+ public const XML_PATH_CUSTOMER_CAPTCHA_ENABLED = 'customer/captcha/enable ' ;
23
+
19
24
/**
20
25
* Current module pathname
21
26
*
You can’t perform that action at this time.
0 commit comments