/**
  * @return void
  */
 public function testIsResetPasswordLinkTokenExpiredIsNotExpiredToken()
 {
     $this->model->setRpToken('1');
     $this->model->setRpTokenCreatedAt((new \DateTime())->format(\Magento\Framework\Stdlib\DateTime::DATETIME_PHP_FORMAT));
     $this->userDataMock->expects($this->once())->method('getResetPasswordLinkExpirationPeriod')->willReturn(1);
     $this->assertFalse($this->model->isResetPasswordLinkTokenExpired());
 }
Пример #2
0
 /**
  * Check if current reset password link token is expired
  *
  * @return bool
  */
 public function isResetPasswordLinkTokenExpired()
 {
     $linkToken = $this->getRpToken();
     $linkTokenCreatedAt = $this->getRpTokenCreatedAt();
     if (empty($linkToken) || empty($linkTokenCreatedAt)) {
         return true;
     }
     $expirationPeriod = $this->_userData->getResetPasswordLinkExpirationPeriod();
     $currentTimestamp = (new \DateTime())->getTimestamp();
     $tokenTimestamp = (new \DateTime($linkTokenCreatedAt))->getTimestamp();
     if ($tokenTimestamp > $currentTimestamp) {
         return true;
     }
     $dayDifference = floor(($currentTimestamp - $tokenTimestamp) / (24 * 60 * 60));
     if ($dayDifference >= $expirationPeriod) {
         return true;
     }
     return false;
 }
Пример #3
0
 public function testGetResetPasswordLinkExpirationPeriod()
 {
     $value = '123';
     $this->configMock->expects($this->once())->method('getValue')->with(\Magento\User\Helper\Data::XML_PATH_ADMIN_RESET_PASSWORD_LINK_EXPIRATION_PERIOD)->willReturn($value);
     $this->assertEquals((int) $value, $this->model->getResetPasswordLinkExpirationPeriod());
 }