Skip to content

Commit db2fd53

Browse files
ENGCOM-9215: Fixed customertoken not generating after configured failure in a row #34001
- Merge Pull Request #34001 from sagar2009kumar/magento2:2.4-develop - Merged commits: 1. c1290c5 2. c76bbe6 3. 9c079dc 4. e89bd3d 5. d0fa57e
2 parents eea292a + d0fa57e commit db2fd53

File tree

1 file changed

+23
-7
lines changed
  • app/code/Magento/Integration/Model/ResourceModel/Oauth/Token

1 file changed

+23
-7
lines changed

app/code/Magento/Integration/Model/ResourceModel/Oauth/Token/RequestLog.php

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,27 +46,41 @@ public function __construct(
4646
}
4747

4848
/**
49-
* {@inheritdoc}
49+
* @inheritdoc
5050
*/
5151
protected function _construct()
5252
{
5353
$this->_init('oauth_token_request_log', 'entity_id');
5454
}
5555

5656
/**
57-
* {@inheritdoc}
57+
* @inheritdoc
58+
* @param string $userName
59+
* @param int $userType
5860
*/
5961
public function getFailuresCount($userName, $userType)
6062
{
63+
$date = (new \DateTime())->setTimestamp($this->dateTime->gmtTimestamp());
64+
$dateTime = $date->format(\Magento\Framework\Stdlib\DateTime::DATETIME_PHP_FORMAT);
65+
6166
$select = $this->getConnection()->select();
6267
$select->from($this->getMainTable(), 'failures_count')
63-
->where('user_name = :user_name AND user_type = :user_type');
68+
->where('user_name = :user_name AND user_type = :user_type AND lock_expires_at > :expiration_time');
6469

65-
return (int)$this->getConnection()->fetchOne($select, ['user_name' => $userName, 'user_type' => $userType]);
70+
return (int)$this->getConnection()->fetchOne(
71+
$select,
72+
[
73+
'user_name' => $userName,
74+
'user_type' => $userType,
75+
'expiration_time' => $dateTime,
76+
]
77+
);
6678
}
6779

6880
/**
69-
* {@inheritdoc}
81+
* @inheritdoc
82+
* @param string $userName
83+
* @param int $userType
7084
*/
7185
public function resetFailuresCount($userName, $userType)
7286
{
@@ -77,7 +91,9 @@ public function resetFailuresCount($userName, $userType)
7791
}
7892

7993
/**
80-
* {@inheritdoc}
94+
* @inheritdoc
95+
* @param string $userName
96+
* @param int $userType
8197
*/
8298
public function incrementFailuresCount($userName, $userType)
8399
{
@@ -101,7 +117,7 @@ public function incrementFailuresCount($userName, $userType)
101117
}
102118

103119
/**
104-
* {@inheritdoc}
120+
* @inheritdoc
105121
*/
106122
public function clearExpiredFailures()
107123
{

0 commit comments

Comments
 (0)