Skip to content

Commit 55b1a09

Browse files
author
lakshmana
committed
ACP2E-1646 : Page Builder CORS errors prevent product save.
1 parent 477fcf8 commit 55b1a09

File tree

1 file changed

+14
-3
lines changed
  • app/code/Magento/PageBuilder/Component/Form/Element

1 file changed

+14
-3
lines changed

app/code/Magento/PageBuilder/Component/Form/Element/Wysiwyg.php

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use Magento\PageBuilder\Model\Config as PageBuilderConfig;
1919
use Magento\PageBuilder\Model\State as PageBuilderState;
2020
use Magento\PageBuilder\Model\Stage\Config as Config;
21+
use Magento\Framework\AuthorizationInterface;
2122

2223
/**
2324
* Updates wysiwyg element with Page Builder specific config
@@ -26,11 +27,19 @@
2627
*/
2728
class Wysiwyg extends \Magento\Ui\Component\Form\Element\Wysiwyg
2829
{
30+
31+
public const ADMIN_RESOURCE = 'Magento_Backend::content';
32+
2933
/**
3034
* @var Repository
3135
*/
3236
private $assetRepo;
3337

38+
/**
39+
* @var AuthorizationInterface
40+
*/
41+
private $authorization;
42+
3443
/**
3544
* WYSIWYG Constructor
3645
*
@@ -62,9 +71,11 @@ public function __construct(
6271
array $config = [],
6372
PageBuilderConfig $pageBuilderConfig = null,
6473
bool $overrideSnapshot = false,
65-
Repository $assetRepo = null
74+
Repository $assetRepo = null,
75+
AuthorizationInterface $authorization = null
6676
) {
6777
$this->assetRepo = $assetRepo ?: ObjectManager::getInstance()->get(Repository::class);
78+
$this->authorization = $authorization ?: ObjectManager::getInstance()->get(AuthorizationInterface::class);
6879
$wysiwygConfigData = $config['wysiwygConfigData'] ?? [];
6980

7081
// If a dataType is present we're dealing with an attribute
@@ -79,11 +90,11 @@ public function __construct(
7990
$config['wysiwyg'] = true;
8091
}
8192
}
82-
93+
$isAllowed = $this->authorization->isAllowed(self::ADMIN_RESOURCE);
8394
$isEnablePageBuilder = isset($wysiwygConfigData['is_pagebuilder_enabled'])
8495
&& !$wysiwygConfigData['is_pagebuilder_enabled']
8596
|| false;
86-
if (!$pageBuilderState->isPageBuilderInUse($isEnablePageBuilder)) {
97+
if (!$pageBuilderState->isPageBuilderInUse($isEnablePageBuilder) && $isAllowed) {
8798
// This is not done using definition.xml due to https://github.com/magento/magento2/issues/5647
8899
$data['config']['component'] = 'Magento_PageBuilder/js/form/element/wysiwyg';
89100

0 commit comments

Comments
 (0)