7
7
namespace Magento \Sales \Controller \AbstractController ;
8
8
9
9
use Magento \Framework \App \Action ;
10
+ use Magento \Framework \Data \Form \FormKey \Validator ;
10
11
use Magento \Framework \Registry ;
11
12
use Magento \Framework \Exception \NotFoundException ;
12
13
@@ -22,18 +23,26 @@ abstract class Reorder extends Action\Action
22
23
*/
23
24
protected $ _coreRegistry ;
24
25
26
+ /**
27
+ * @var Validator
28
+ */
29
+ private $ formKeyValidator ;
30
+
25
31
/**
26
32
* @param Action\Context $context
27
33
* @param OrderLoaderInterface $orderLoader
28
34
* @param Registry $registry
35
+ * @param Validator|null $formKeyValidator
29
36
*/
30
37
public function __construct (
31
38
Action \Context $ context ,
32
39
OrderLoaderInterface $ orderLoader ,
33
- Registry $ registry
40
+ Registry $ registry ,
41
+ Validator $ formKeyValidator = null
34
42
) {
35
43
$ this ->orderLoader = $ orderLoader ;
36
44
$ this ->_coreRegistry = $ registry ;
45
+ $ this ->formKeyValidator = $ formKeyValidator ;
37
46
parent ::__construct ($ context );
38
47
}
39
48
@@ -44,7 +53,7 @@ public function __construct(
44
53
*/
45
54
public function execute ()
46
55
{
47
- if (!$ this ->getRequest ()->isPost ()) {
56
+ if (!$ this ->getRequest ()->isPost () || ! $ this -> formKeyValidator -> validate ( $ this -> getRequest ()) ) {
48
57
throw new NotFoundException (__ ('Page not found. ' ));
49
58
return ;
50
59
}
0 commit comments