21
21
use Magento \User \Model \User ;
22
22
use Magento \Framework \App \Config \ScopeConfigInterface ;
23
23
use Magento \User \Model \ResourceModel \User as UserResource ;
24
+ use Magento \Framework \App \ObjectManager ;
24
25
25
26
/**
26
27
* @SuppressWarnings(PHPMD.CamelCaseMethodName)
@@ -80,7 +81,7 @@ class Authpost extends AbstractAction implements HttpPostActionInterface
80
81
/**
81
82
* @var UserResource
82
83
*/
83
- protected $ userResource ;
84
+ private $ userResource ;
84
85
85
86
/**
86
87
* @param Action\Context $context
@@ -91,8 +92,8 @@ class Authpost extends AbstractAction implements HttpPostActionInterface
91
92
* @param TfaInterface $tfa
92
93
* @param AlertInterface $alert
93
94
* @param DataObjectFactory $dataObjectFactory
94
- * @param UserResource $userResource
95
- * @param ScopeConfigInterface $scopeConfig
95
+ * @param UserResource|null $userResource
96
+ * @param ScopeConfigInterface|null $scopeConfig
96
97
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
97
98
*/
98
99
public function __construct (
@@ -104,8 +105,8 @@ public function __construct(
104
105
TfaInterface $ tfa ,
105
106
AlertInterface $ alert ,
106
107
DataObjectFactory $ dataObjectFactory ,
107
- UserResource $ userResource ,
108
- ScopeConfigInterface $ scopeConfig
108
+ ? UserResource $ userResource = null ,
109
+ ? ScopeConfigInterface $ scopeConfig = null
109
110
) {
110
111
parent ::__construct ($ context );
111
112
$ this ->tfa = $ tfa ;
@@ -115,8 +116,8 @@ public function __construct(
115
116
$ this ->authy = $ authy ;
116
117
$ this ->dataObjectFactory = $ dataObjectFactory ;
117
118
$ this ->alert = $ alert ;
118
- $ this ->userResource = $ userResource ;
119
- $ this ->scopeConfig = $ scopeConfig ;
119
+ $ this ->scopeConfig = $ scopeConfig ?? ObjectManager:: getInstance ()-> get (ScopeConfigInterface::class) ;
120
+ $ this ->userResource = $ userResource ?? ObjectManager:: getInstance ()-> get (UserResource::class) ;
120
121
}
121
122
122
123
/**
@@ -140,7 +141,7 @@ public function execute()
140
141
try {
141
142
if (!$ this ->allowApiRetries ()) { //locked the user
142
143
$ lockThreshold = $ this ->scopeConfig ->getValue (self ::XML_PATH_2FA_LOCK_EXPIRE );
143
- if ($ this ->userResource ->lock ($ user ->getId (), 0 , $ lockThreshold )) {
144
+ if ($ this ->userResource ->lock (( int ) $ user ->getId (), 0 , $ lockThreshold )) {
144
145
$ result ->setData (['success ' => false , 'message ' => "Your account is temporarily disabled. " ]);
145
146
return $ result ;
146
147
}
0 commit comments