28 private $collectionFactory;
33 private $securityConfig;
38 private $remoteAddress;
49 \
Magento\Framework\Stdlib\DateTime\DateTime $dateTime,
52 $this->securityConfig = $securityConfig;
53 $this->collectionFactory = $collectionFactory;
55 $this->remoteAddress = $remoteAddress;
61 public function check($securityEventType, $accountReference =
null, $longIp =
null)
64 $limitTimeBetweenRequests = $this->securityConfig->getMinTimeBetweenPasswordResetRequests();
65 if ($isEnabled && $limitTimeBetweenRequests) {
66 if (
null === $longIp) {
67 $longIp = $this->remoteAddress->getRemoteAddress();
69 $lastRecordCreationTimestamp = $this->loadLastRecordCreationTimestamp(
74 if ($lastRecordCreationTimestamp && (
75 $limitTimeBetweenRequests >
76 ($this->dateTime->gmtTimestamp() - $lastRecordCreationTimestamp)
80 'We received too many requests for password resets. ' 81 .
'Please wait and try again later or contact %1.',
82 $this->securityConfig->getCustomerServiceEmail()
97 private function loadLastRecordCreationTimestamp($securityEventType, $accountReference, $longIp)
99 $collection = $this->collectionFactory->create($securityEventType, $accountReference, $longIp);
101 $record =
$collection->filterLastItem()->getFirstItem();
103 return (
int) strtotime($record->getCreatedAt());
check($securityEventType, $accountReference=null, $longIp=null)
__construct(ConfigInterface $securityConfig, CollectionFactory $collectionFactory, \Magento\Framework\Stdlib\DateTime\DateTime $dateTime, RemoteAddress $remoteAddress)