2121use Magento \User \Model \User ;
2222use Magento \Framework \App \Config \ScopeConfigInterface ;
2323use Magento \User \Model \ResourceModel \User as UserResource ;
24+ use Magento \Framework \App \ObjectManager ;
2425
2526/**
2627 * @SuppressWarnings(PHPMD.CamelCaseMethodName)
@@ -80,7 +81,7 @@ class Authpost extends AbstractAction implements HttpPostActionInterface
8081 /**
8182 * @var UserResource
8283 */
83- protected $ userResource ;
84+ private $ userResource ;
8485
8586 /**
8687 * @param Action\Context $context
@@ -91,8 +92,8 @@ class Authpost extends AbstractAction implements HttpPostActionInterface
9192 * @param TfaInterface $tfa
9293 * @param AlertInterface $alert
9394 * @param DataObjectFactory $dataObjectFactory
94- * @param UserResource $userResource
95- * @param ScopeConfigInterface $scopeConfig
95+ * @param UserResource|null $userResource
96+ * @param ScopeConfigInterface|null $scopeConfig
9697 * @SuppressWarnings(PHPMD.ExcessiveParameterList)
9798 */
9899 public function __construct (
@@ -104,8 +105,8 @@ public function __construct(
104105 TfaInterface $ tfa ,
105106 AlertInterface $ alert ,
106107 DataObjectFactory $ dataObjectFactory ,
107- UserResource $ userResource ,
108- ScopeConfigInterface $ scopeConfig
108+ ? UserResource $ userResource = null ,
109+ ? ScopeConfigInterface $ scopeConfig = null
109110 ) {
110111 parent ::__construct ($ context );
111112 $ this ->tfa = $ tfa ;
@@ -115,8 +116,8 @@ public function __construct(
115116 $ this ->authy = $ authy ;
116117 $ this ->dataObjectFactory = $ dataObjectFactory ;
117118 $ 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) ;
120121 }
121122
122123 /**
@@ -140,7 +141,7 @@ public function execute()
140141 try {
141142 if (!$ this ->allowApiRetries ()) { //locked the user
142143 $ 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 )) {
144145 $ result ->setData (['success ' => false , 'message ' => "Your account is temporarily disabled. " ]);
145146 return $ result ;
146147 }
0 commit comments