10
10
11
11
use Magento \Framework \Controller \ResultFactory ;
12
12
use Magento \Framework \App \Action \HttpPostActionInterface ;
13
+ use Magento \Framework \Exception \AuthenticationException ;
13
14
14
15
/**
15
16
* Preview controller to render blocks preview on Stage
@@ -26,28 +27,40 @@ class Preview extends \Magento\Framework\App\Action\Action implements HttpPostAc
26
27
*/
27
28
private $ rendererPool ;
28
29
30
+ /**
31
+ * @var \Magento\Backend\Model\Auth
32
+ */
33
+ protected $ auth ;
34
+
29
35
/**
30
36
* Constructor
31
37
*
32
38
* @param \Magento\Backend\App\Action\Context $context
33
39
* @param \Magento\PageBuilder\Model\Stage\RendererPool $rendererPool
40
+ * @param \Magento\Backend\Model\Auth $auth
34
41
*/
35
42
public function __construct (
36
43
\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
38
46
) {
39
47
parent ::__construct ($ context );
40
48
41
49
$ this ->rendererPool = $ rendererPool ;
50
+ $ this ->auth = $ auth ;
42
51
}
43
52
44
53
/**
45
54
* Generates an HTML preview for the stage
46
55
*
47
56
* @return \Magento\Framework\Controller\ResultInterface
57
+ * @throws \Magento\Framework\Exception\AuthenticationException
48
58
*/
49
59
public function execute ()
50
60
{
61
+ if (!$ this ->auth ->isLoggedIn ()) {
62
+ throw new AuthenticationException (__ ('An authentication error occurred. Verify and try again. ' ));
63
+ }
51
64
$ pageResult = $ this ->resultFactory ->create (ResultFactory::TYPE_PAGE );
52
65
// Some template filters and directive processors expect this to be called in order to function.
53
66
$ pageResult ->initLayout ();
0 commit comments