Skip to content

Commit c1290c5

Browse files
Fixed the not expiry of token in generateCustomerToken graphql
When we have more login failure in the api for creation of token than the configured times. It does not allow us to generate new token because there is no any check of 'lock_expires_at'.
1 parent 9b8d557 commit c1290c5

File tree

1 file changed

+5
-2
lines changed
  • app/code/Magento/Integration/Model/ResourceModel/Oauth/Token

1 file changed

+5
-2
lines changed

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,14 @@ protected function _construct()
5858
*/
5959
public function getFailuresCount($userName, $userType)
6060
{
61+
$date = (new \DateTime())->setTimestamp($this->dateTime->gmtTimestamp());
62+
$dateTime = $date->format(\Magento\Framework\Stdlib\DateTime::DATETIME_PHP_FORMAT);
63+
6164
$select = $this->getConnection()->select();
6265
$select->from($this->getMainTable(), 'failures_count')
63-
->where('user_name = :user_name AND user_type = :user_type');
66+
->where('user_name = :user_name AND user_type = :user_type AND lock_expires_at > :expiration_time');
6467

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

6871
/**

0 commit comments

Comments
 (0)