/** * {@inheritdoc} */ public function check($securityEventType, $accountReference = null, $longIp = null) { $isEnabled = $this->securityConfig->getPasswordResetProtectionType() != ResetMethod::OPTION_NONE; $allowedAttemptsNumber = $this->securityConfig->getMaxNumberPasswordResetRequests(); if ($isEnabled and $allowedAttemptsNumber) { $collection = $this->prepareCollection($securityEventType, $accountReference, $longIp); if ($collection->count() >= $allowedAttemptsNumber) { throw new SecurityViolationException(__('Too many password reset requests. Please wait and try again or contact %1.', $this->securityConfig->getCustomerServiceEmail())); } } }
/** * @param int $limitNumber * @param int $scope * @dataProvider dataProviderNumberValueWithScope */ public function testGetMaxNumberPasswordResetRequests($limitNumber, $scope) { $this->scopeConfigMock->expects($this->once())->method('getValue')->with($this->getXmlPathPrefix($scope) . \Magento\Security\Model\Config::XML_PATH_MAX_NUMBER_PASSWORD_RESET_REQUESTS)->willReturn($limitNumber); $this->scopeMock->expects($this->once())->method('getCurrentScope')->willReturn($scope); $this->assertEquals($limitNumber, $this->model->getMaxNumberPasswordResetRequests()); }