diff --git a/Block/System/Config/LiveChatForm.php b/Block/System/Config/LiveChatForm.php index 0c1c39c..2b954b0 100644 --- a/Block/System/Config/LiveChatForm.php +++ b/Block/System/Config/LiveChatForm.php @@ -11,6 +11,7 @@ class LiveChatForm extends \Magento\Framework\View\Element\Template const CHECK_TEMPLATE = 'system/config/livechat_form.phtml'; private $dataHelper; + private $urlinterface; public function __construct( \Magento\Framework\View\Element\Template\Context $context, diff --git a/Controller/Adminhtml/GetProps/Index.php b/Controller/Adminhtml/GetProps/Index.php index e8837a0..0db5b1e 100644 --- a/Controller/Adminhtml/GetProps/Index.php +++ b/Controller/Adminhtml/GetProps/Index.php @@ -10,6 +10,14 @@ class Index extends \Magento\Backend\App\Action protected $configWriter; private $cacheManagerFactory; + /** + * @var Data + */ + private $dataHelper; + /** + * @var \Magento\Framework\Controller\Result\JsonFactory + */ + private $resultJsonFactory; public function __construct( Context $context, diff --git a/Controller/Adminhtml/ResetLicense/Index.php b/Controller/Adminhtml/ResetLicense/Index.php index f5d5c2c..5130924 100644 --- a/Controller/Adminhtml/ResetLicense/Index.php +++ b/Controller/Adminhtml/ResetLicense/Index.php @@ -7,6 +7,14 @@ class Index extends \Magento\Backend\App\Action { protected $resultPageFactory; protected $configWriter; + /** + * @var \Magento\Framework\Controller\Result\JsonFactory + */ + private $resultJsonFactory; + /** + * @var \Magento\Framework\App\Cache\ManagerFactory + */ + private $cacheManagerFactory; public function __construct( Context $context, diff --git a/Controller/Adminhtml/SetLicense/Index.php b/Controller/Adminhtml/SetLicense/Index.php index 0ad8bec..6243d8a 100644 --- a/Controller/Adminhtml/SetLicense/Index.php +++ b/Controller/Adminhtml/SetLicense/Index.php @@ -7,6 +7,14 @@ class Index extends \Magento\Backend\App\Action { protected $resultPageFactory; protected $configWriter; + /** + * @var \Magento\Framework\Controller\Result\JsonFactory + */ + private $resultJsonFactory; + /** + * @var \Magento\Framework\App\Cache\ManagerFactory + */ + private $cacheManagerFactory; public function __construct( Context $context, diff --git a/Controller/Adminhtml/SetProps/Index.php b/Controller/Adminhtml/SetProps/Index.php index 3592745..496b162 100644 --- a/Controller/Adminhtml/SetProps/Index.php +++ b/Controller/Adminhtml/SetProps/Index.php @@ -9,6 +9,10 @@ class Index extends \Magento\Backend\App\Action protected $configWriter; private $cacheManagerFactory; + /** + * @var \Magento\Framework\Controller\Result\JsonFactory + */ + private $resultJsonFactory; public function __construct( Context $context, diff --git a/composer.json b/composer.json index 7690763..7ee029c 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,7 @@ "magento/framework": "100.*|101.*|102.*|103.*" }, "type": "magento2-module", - "version": "2.4.8", + "version": "2.4.9", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/view/adminhtml/templates/system/config/livechat_form.phtml b/view/adminhtml/templates/system/config/livechat_form.phtml index 0db238d..94231ce 100644 --- a/view/adminhtml/templates/system/config/livechat_form.phtml +++ b/view/adminhtml/templates/system/config/livechat_form.phtml @@ -7,7 +7,7 @@ -
+
diff --git a/view/adminhtml/web/script.js b/view/adminhtml/web/script.js index 5361952..2c62638 100644 --- a/view/adminhtml/web/script.js +++ b/view/adminhtml/web/script.js @@ -1,5 +1,6 @@ require(['jquery'], function ($) { - + + var addonsOrigin = 'https://addons.livechatinc.com'; var save_props_url = $('#save-props-url').html(); var save_license_url = $('#save-license-url').html(); var reset_license_url = $('#reset-license-url').html(); @@ -57,7 +58,7 @@ require(['jquery'], function ($) { }); var sendMessage = function (msg) { - login_with_livechat.contentWindow.postMessage(msg, '*'); + login_with_livechat.contentWindow.postMessage(msg, addonsOrigin); }; var logoutLiveChat = function () { @@ -65,15 +66,21 @@ require(['jquery'], function ($) { }; function receiveMessage(event) { + if (event.origin !== addonsOrigin) { + return; + } + + var livechatMessage; + try { - var livechatMessage = JSON.parse(event.data); + livechatMessage = JSON.parse(event.data); } catch(err) { + console.log(err?.message); console.log(JSON.stringify(err)); } - if (livechatMessage.type === 'logged-in' && livechatMessage.eventTrigger === 'click') { - + if (livechatMessage?.type === 'logged-in' && livechatMessage?.eventTrigger === 'click') { $('#login_panel').hide(); $('#admin_panel').show(); $('iframe#login-with-livechat').addClass('hidden');