Skip to content

Commit e644557

Browse files
Rizwan KhanRizwan Khan
authored andcommitted
AC-9797: 2FA functionality enhancement
1 parent 25d28a8 commit e644557

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

TwoFactorAuth/Controller/Adminhtml/Authy/Authpost.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ class Authpost extends AbstractAction implements HttpPostActionInterface
9393
* @param DataObjectFactory $dataObjectFactory
9494
* @param UserResource $userResource
9595
* @param ScopeConfigInterface $scopeConfig
96+
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
9697
*/
9798
public function __construct(
9899
Action\Context $context,
@@ -141,7 +142,7 @@ public function execute()
141142
$retries = $this->verifyRetryAttempts();
142143
if ($retries > $maxRetries) { //locked the user
143144
$lockThreshold = $this->scopeConfig->getValue(self::XML_PATH_2FA_LOCK_EXPIRE);
144-
if ($this->userResource->lock($user->getId(),0, $lockThreshold)) {
145+
if ($this->userResource->lock($user->getId(), 0, $lockThreshold)) {
145146
$result->setData(['success' => false, 'message' => "User is disabled temporarily!"]);
146147
}
147148
} else {
@@ -187,7 +188,7 @@ protected function _isAllowed()
187188
private function verifyRetryAttempts() : int
188189
{
189190
$verifyAttempts = $this->session->getOtpAttempt();
190-
$verifyAttempts = is_null($verifyAttempts) ? 0 : $verifyAttempts+1;
191+
$verifyAttempts = $verifyAttempts === null ? 1 : $verifyAttempts+1;
191192
$this->session->setOtpAttempt($verifyAttempts);
192193
return $verifyAttempts;
193194
}

TwoFactorAuth/Controller/Adminhtml/Google/Authpost.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ class Authpost extends AbstractAction implements HttpPostActionInterface
9494
* @param DataObjectFactory $dataObjectFactory
9595
* @param UserResource $userResource
9696
* @param ScopeConfigInterface $scopeConfig
97+
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
9798
*/
9899
public function __construct(
99100
Action\Context $context,
@@ -135,7 +136,7 @@ public function execute()
135136
$retries = $this->verifyRetryAttempts();
136137
if ($retries > $maxRetries) { //locked the user
137138
$lockThreshold = $this->scopeConfig->getValue(self::XML_PATH_2FA_LOCK_EXPIRE);
138-
if ($this->userResource->lock($user->getId(),0, $lockThreshold)) {
139+
if ($this->userResource->lock($user->getId(), 0, $lockThreshold)) {
139140
$response->setData(['success' => false, 'message' => "User is disabled temporarily!"]);
140141
}
141142
} else {
@@ -179,7 +180,7 @@ protected function _isAllowed()
179180
private function verifyRetryAttempts() : int
180181
{
181182
$verifyAttempts = $this->session->getOtpAttempt();
182-
$verifyAttempts = is_null($verifyAttempts) ? 0 : $verifyAttempts+1;
183+
$verifyAttempts = $verifyAttempts === null ? 1 : $verifyAttempts+1;
183184
$this->session->setOtpAttempt($verifyAttempts);
184185
return $verifyAttempts;
185186
}

TwoFactorAuth/etc/adminhtml/system.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
showInDefault="1" showInWebsite="0" showInStore="0">
3535
<label>Configuration Email URL for Web API</label>
3636
<comment>This can be used to override the default email configuration link that is sent when using the Magento Web API's to authenticate. Use the placeholder :tfat to indicate where the token should be injected</comment>
37-
</field>x
37+
</field>
3838
<field canRestore="1" id="twofactorauth_retry" translate="label" type="text" sortOrder="40"
3939
showInDefault="1" showInWebsite="0" showInStore="0">
4040
<label>Configuration for 2FA retry attempts</label>

0 commit comments

Comments
 (0)