コード例 #1
0
ファイル: Quantity.php プロジェクト: Doability/magento2dev
 /**
  * {@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()));
         }
     }
 }
コード例 #2
0
ファイル: Frequency.php プロジェクト: Doability/magento2dev
 /**
  * {@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()));
         }
     }
 }
コード例 #3
0
ファイル: ConfigTest.php プロジェクト: Doability/magento2dev
 /**
  * Test get customer service email
  * @return void
  */
 public function testGetCustomerServiceEmail()
 {
     $email = '*****@*****.**';
     $this->scopeConfigMock->expects($this->once())->method('getValue')->with(\Magento\Security\Model\Config::XML_PATH_EMAIL_RECIPIENT, \Magento\Store\Model\ScopeInterface::SCOPE_STORE)->will($this->returnValue($email));
     $this->assertEquals($email, $this->model->getCustomerServiceEmail());
 }