Skip to content

Fixed customertoken not generating after configured failure in a row #34001

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Sep 23, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,27 +46,41 @@ public function __construct(
}

/**
* {@inheritdoc}
* @inheritdoc
*/
protected function _construct()
{
$this->_init('oauth_token_request_log', 'entity_id');
}

/**
* {@inheritdoc}
* @inheritdoc
* @param string $userName
* @param int $userType
*/
public function getFailuresCount($userName, $userType)
{
$date = (new \DateTime())->setTimestamp($this->dateTime->gmtTimestamp());
$dateTime = $date->format(\Magento\Framework\Stdlib\DateTime::DATETIME_PHP_FORMAT);

$select = $this->getConnection()->select();
$select->from($this->getMainTable(), 'failures_count')
->where('user_name = :user_name AND user_type = :user_type');
->where('user_name = :user_name AND user_type = :user_type AND lock_expires_at > :expiration_time');

return (int)$this->getConnection()->fetchOne($select, ['user_name' => $userName, 'user_type' => $userType]);
return (int)$this->getConnection()->fetchOne(
$select,
[
'user_name' => $userName,
'user_type' => $userType,
'expiration_time' => $dateTime,
]
);
}

/**
* {@inheritdoc}
* @inheritdoc
* @param string $userName
* @param int $userType
*/
public function resetFailuresCount($userName, $userType)
{
Expand All @@ -77,7 +91,9 @@ public function resetFailuresCount($userName, $userType)
}

/**
* {@inheritdoc}
* @inheritdoc
* @param string $userName
* @param int $userType
*/
public function incrementFailuresCount($userName, $userType)
{
Expand All @@ -101,7 +117,7 @@ public function incrementFailuresCount($userName, $userType)
}

/**
* {@inheritdoc}
* @inheritdoc
*/
public function clearExpiredFailures()
{
Expand Down