Ejemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function check($securityEventType, $accountReference = null, $longIp = null)
 {
     $isEnabled = $this->securityConfig->getPasswordResetProtectionType() != ResetMethod::OPTION_NONE;
     $limitTimeBetweenRequests = $this->securityConfig->getMinTimeBetweenPasswordResetRequests();
     if ($isEnabled && $limitTimeBetweenRequests) {
         if (null === $longIp) {
             $longIp = $this->remoteAddress->getRemoteAddress();
         }
         $lastRecordCreationTimestamp = $this->loadLastRecordCreationTimestamp($securityEventType, $accountReference, $longIp);
         if ($lastRecordCreationTimestamp && $limitTimeBetweenRequests > $this->dateTime->gmtTimestamp() - $lastRecordCreationTimestamp) {
             throw new SecurityViolationException(__('Too many password reset requests. Please wait and try again or contact %1.', $this->securityConfig->getCustomerServiceEmail()));
         }
     }
 }
Ejemplo n.º 2
0
 /**
  * @param int $limitTime
  * @param int $scope
  * @dataProvider dataProviderNumberValueWithScope
  */
 public function testGetMinTimeBetweenPasswordResetRequests($limitTime, $scope)
 {
     $this->scopeConfigMock->expects($this->once())->method('getValue')->with($this->getXmlPathPrefix($scope) . \Magento\Security\Model\Config::XML_PATH_MIN_TIME_BETWEEN_PASSWORD_RESET_REQUESTS)->willReturn($limitTime);
     $this->scopeMock->expects($this->once())->method('getCurrentScope')->willReturn($scope);
     $this->assertEquals($limitTime * 60, $this->model->getMinTimeBetweenPasswordResetRequests());
 }