diff --git a/app/code/Magento/Integration/Model/ResourceModel/Oauth/Token/RequestLog.php b/app/code/Magento/Integration/Model/ResourceModel/Oauth/Token/RequestLog.php index d94297bbcf46e..07112a33f3886 100644 --- a/app/code/Magento/Integration/Model/ResourceModel/Oauth/Token/RequestLog.php +++ b/app/code/Magento/Integration/Model/ResourceModel/Oauth/Token/RequestLog.php @@ -46,7 +46,7 @@ public function __construct( } /** - * {@inheritdoc} + * @inheritdoc */ protected function _construct() { @@ -54,19 +54,33 @@ protected function _construct() } /** - * {@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) { @@ -77,7 +91,9 @@ public function resetFailuresCount($userName, $userType) } /** - * {@inheritdoc} + * @inheritdoc + * @param string $userName + * @param int $userType */ public function incrementFailuresCount($userName, $userType) { @@ -101,7 +117,7 @@ public function incrementFailuresCount($userName, $userType) } /** - * {@inheritdoc} + * @inheritdoc */ public function clearExpiredFailures() {