Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable captcha storefont config still load captcha js files #39154

Open
wants to merge 26 commits into
base: 2.4-develop
Choose a base branch
from
Open
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
ae7bfb6
Disable captcha storefont config still load captcha js files
rogerdz Sep 10, 2024
510cf9b
update code
rogerdz Sep 11, 2024
d6ab658
Merge branch '2.4-develop' into fix-32987
rogerdz Sep 11, 2024
9511324
Merge branch '2.4-develop' into fix-32987
engcom-Hotel Feb 18, 2025
5f2c7c5
Merge branch '2.4-develop' into fix-32987
engcom-Hotel Feb 25, 2025
899e339
Merge branch '2.4-develop' into fix-32987
engcom-Hotel Feb 26, 2025
d2860ce
Fix the static test failures and improve code readability
engcom-Hotel Feb 26, 2025
fd0b159
Fix static test failures
engcom-Hotel Feb 26, 2025
ed76de5
Merge branch '2.4-develop' into fix-32987
engcom-Hotel Feb 27, 2025
c2c85ce
Fix integration test failures
glo24157 Feb 27, 2025
212214f
Merge branch '2.4-develop' into fix-32987
engcom-Hotel Feb 27, 2025
315dc25
Fixes integration test failures
glo24157 Feb 28, 2025
047da16
Fixes static test failures
engcom-Hotel Feb 28, 2025
16e3557
Update code according to the review comment
engcom-Hotel Mar 5, 2025
bc97c90
Merge branch '2.4-develop' into fix-32987
engcom-Hotel Mar 5, 2025
6c1f4f3
Fixed static test failures
engcom-Hotel Mar 5, 2025
4960a84
Merge branch '2.4-develop' into fix-32987
engcom-Hotel Mar 6, 2025
df37b87
Fix review comment
engcom-Hotel Mar 6, 2025
5edd1a4
Fix review comments
engcom-Hotel Mar 10, 2025
03651fd
Merge branch '2.4-develop' into fix-32987
engcom-Hotel Mar 10, 2025
e7e56a9
Add Layout Processor
engcom-Hotel Mar 10, 2025
9619454
Removed some file and unused code
engcom-Hotel Mar 10, 2025
fe11f9a
Fixes review comments
engcom-Hotel Mar 13, 2025
ba8bc52
Merge branch '2.4-develop' into fix-32987
engcom-Hotel Mar 13, 2025
cfdc12c
Fix static test failures
engcom-Hotel Mar 18, 2025
560b3be
Merge branch '2.4-develop' into fix-32987
engcom-Dash Mar 21, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions app/code/Magento/Captcha/Block/CheckoutLayoutProcessor.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php
/**
* Copyright 2025 Adobe.
* All Rights Reserved.
*/

declare(strict_types=1);
namespace Magento\Captcha\Block;

use Magento\Checkout\Block\Checkout\LayoutProcessorInterface;
use Magento\Captcha\Helper\Data as HelperCaptcha;

class CheckoutLayoutProcessor implements LayoutProcessorInterface
{
/**
* @param HelperCaptcha $helper
*/
public function __construct(
private readonly HelperCaptcha $helper
) {
}

/**
* Remove captcha from checkout page if it is disabled
*
* @param array $jsLayout
* @return array
*/
public function process($jsLayout): array
{
if ($this->helper->getConfig('enable')) {
$captcha = [
'component' => 'Magento_Captcha/js/view/checkout/loginCaptcha',
'displayArea' => 'additional-login-form-fields',
'formId' => 'user_login',
'configSource' => 'checkoutConfig'
];
$jsLayout['components']['checkout']['children']['authentication']['children']['captcha'] = $captcha;
$jsLayout['components']['checkout']['children']['steps']['children']['shipping-step']['children']
['shippingAddress']['children']['customer-email']['children']['additional-login-form-fields']
['children']['captcha'] = $captcha;
}
return $jsLayout;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php
/**
* Copyright 2025 Adobe.
* All Rights Reserved.
*/

declare(strict_types=1);
namespace Magento\Captcha\Block\Customer\AuthenticationPopup;

use Magento\Captcha\Helper\Data as HelperCaptcha;
use Magento\Checkout\Block\Checkout\LayoutProcessorInterface;

class LayoutProcessor implements LayoutProcessorInterface
{
/**
* @param HelperCaptcha $helper
*/
public function __construct(
private readonly HelperCaptcha $helper
) {
}

/**
* Process jsLayout of checkout page
*
* @param array $jsLayout
* @return array
*/
public function process($jsLayout): array
{
if ($this->helper->getConfig('enable')) {
$jsLayout['components']['authenticationPopup']['children']['captcha'] = [
'component' => 'Magento_Captcha/js/view/checkout/loginCaptcha',
'displayArea' => 'additional-login-form-fields',
'formId' => 'user_login',
'configSource' => 'checkout'
];
}
return $jsLayout;
}
}
18 changes: 16 additions & 2 deletions app/code/Magento/Captcha/etc/frontend/di.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
* Copyright 2015 Adobe
* All Rights Reserved.
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
@@ -37,4 +37,18 @@
<type name="Magento\Sales\Api\OrderManagementInterface">
<plugin name="reset_payment_attempts_after_order_is_placed_plugin" type="Magento\Captcha\Plugin\ResetPaymentAttemptsAfterOrderIsPlacedPlugin"/>
</type>
<type name="Magento\Checkout\Block\Onepage">
<arguments>
<argument name="layoutProcessors" xsi:type="array">
<item name="captcha_processor" xsi:type="object">Magento\Captcha\Block\CheckoutLayoutProcessor</item>
</argument>
</arguments>
</type>
<type name="Magento\Customer\Block\Account\AuthenticationPopup">
<arguments>
<argument name="layoutProcessors" xsi:type="array">
<item name="authentication_popup_processor" xsi:type="object">Magento\Captcha\Block\Customer\AuthenticationPopup\LayoutProcessor</item>
</argument>
</arguments>
</type>
</config>

This file was deleted.

29 changes: 0 additions & 29 deletions app/code/Magento/Captcha/view/frontend/layout/default.xml

This file was deleted.

20 changes: 17 additions & 3 deletions app/code/Magento/Customer/Block/Account/AuthenticationPopup.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
* Copyright 2015 Adobe.
* All Rights Reserved.
*/
namespace Magento\Customer\Block\Account;

use Magento\Framework\App\ObjectManager;
use Magento\Customer\Model\Form;
use Magento\Store\Model\ScopeInterface;
use Magento\Customer\Model\Context;
use Magento\Framework\App\Http\Context as HttpContext;

/**
* @api
@@ -24,21 +27,29 @@ class AuthenticationPopup extends \Magento\Framework\View\Element\Template
*/
private $serializer;

/**
* @var array
*/
private $layoutProcessors;

/**
* @param \Magento\Framework\View\Element\Template\Context $context
* @param array $data
* @param \Magento\Framework\Serialize\Serializer\Json|null $serializer
* @param array $layoutProcessors
* @throws \RuntimeException
*/
public function __construct(
\Magento\Framework\View\Element\Template\Context $context,
array $data = [],
?\Magento\Framework\Serialize\Serializer\Json $serializer = null
?\Magento\Framework\Serialize\Serializer\Json $serializer = null,
array $layoutProcessors = []
) {
parent::__construct($context, $data);
$this->jsLayout = isset($data['jsLayout']) && is_array($data['jsLayout']) ? $data['jsLayout'] : [];
$this->serializer = $serializer ?: \Magento\Framework\App\ObjectManager::getInstance()
->get(\Magento\Framework\Serialize\Serializer\Json::class);
$this->layoutProcessors = $layoutProcessors;
}

/**
@@ -48,6 +59,9 @@ public function __construct(
*/
public function getJsLayout()
{
foreach ($this->layoutProcessors as $processor) {
$this->jsLayout = $processor->process($this->jsLayout);
}
return $this->serializer->serialize($this->jsLayout);
}

4 changes: 2 additions & 2 deletions app/code/Magento/Customer/Model/Form.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
* Copyright 2011 Adobe.
* All Rights Reserved.
*/

namespace Magento\Customer\Model;