Skip to content

Commit 7cd41c6

Browse files
committed
MC-15977: PageBuilder preview
1 parent e9df394 commit 7cd41c6

File tree

1 file changed

+14
-1
lines changed
  • app/code/Magento/PageBuilder/Controller/ContentType

1 file changed

+14
-1
lines changed

app/code/Magento/PageBuilder/Controller/ContentType/Preview.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
use Magento\Framework\Controller\ResultFactory;
1212
use Magento\Framework\App\Action\HttpPostActionInterface;
13+
use Magento\Framework\Exception\AuthenticationException;
1314

1415
/**
1516
* Preview controller to render blocks preview on Stage
@@ -26,28 +27,40 @@ class Preview extends \Magento\Framework\App\Action\Action implements HttpPostAc
2627
*/
2728
private $rendererPool;
2829

30+
/**
31+
* @var \Magento\Backend\Model\Auth
32+
*/
33+
protected $auth;
34+
2935
/**
3036
* Constructor
3137
*
3238
* @param \Magento\Backend\App\Action\Context $context
3339
* @param \Magento\PageBuilder\Model\Stage\RendererPool $rendererPool
40+
* @param \Magento\Backend\Model\Auth $auth
3441
*/
3542
public function __construct(
3643
\Magento\Backend\App\Action\Context $context,
37-
\Magento\PageBuilder\Model\Stage\RendererPool $rendererPool
44+
\Magento\PageBuilder\Model\Stage\RendererPool $rendererPool,
45+
\Magento\Backend\Model\Auth $auth
3846
) {
3947
parent::__construct($context);
4048

4149
$this->rendererPool = $rendererPool;
50+
$this->auth = $auth;
4251
}
4352

4453
/**
4554
* Generates an HTML preview for the stage
4655
*
4756
* @return \Magento\Framework\Controller\ResultInterface
57+
* @throws \Magento\Framework\Exception\AuthenticationException
4858
*/
4959
public function execute()
5060
{
61+
if (!$this->auth->isLoggedIn()) {
62+
throw new AuthenticationException(__('An authentication error occurred. Verify and try again.'));
63+
}
5164
$pageResult = $this->resultFactory->create(ResultFactory::TYPE_PAGE);
5265
// Some template filters and directive processors expect this to be called in order to function.
5366
$pageResult->initLayout();

0 commit comments

Comments
 (0)