62 private $customerAuthUpdate;
90 $now = new \DateTime();
93 $customerSecure = $this->customerRegistry->retrieveSecureData(
$customerId);
95 if (!($lockThreshold && $maxFailures)) {
98 $failuresNum = (int)$customerSecure->getFailuresNum() + 1;
100 $firstFailureDate = $customerSecure->getFirstFailure();
101 if ($firstFailureDate) {
102 $firstFailureDate = new \DateTime($firstFailureDate);
105 $lockThreshInterval = new \DateInterval(
'PT' . $lockThreshold .
'S');
106 $lockExpires = $customerSecure->getLockExpires();
107 $lockExpired = ($lockExpires !==
null) && ($now >
new \
DateTime($lockExpires));
109 if (1 === $failuresNum || !$firstFailureDate || $lockExpired) {
110 $customerSecure->setFirstFailure($this->dateTime->formatDate($now));
112 $customerSecure->setLockExpires(
null);
114 }
elseif ($failuresNum >= $maxFailures) {
115 $customerSecure->setLockExpires($this->dateTime->formatDate($now->add($lockThreshInterval)));
118 $customerSecure->setFailuresNum($failuresNum);
119 $this->getCustomerAuthUpdate()->saveAuth(
$customerId);
127 $customerSecure = $this->customerRegistry->retrieveSecureData(
$customerId);
128 $customerSecure->setFailuresNum(0);
129 $customerSecure->setFirstFailure(
null);
130 $customerSecure->setLockExpires(
null);
131 $this->getCustomerAuthUpdate()->saveAuth(
$customerId);
141 return $this->backendConfig->getValue(self::LOCKOUT_THRESHOLD_PATH) * 60;
151 return $this->backendConfig->getValue(self::MAX_FAILURES_PATH);
159 $currentCustomer = $this->customerRegistry->retrieve(
$customerId);
160 return $currentCustomer->isCustomerLocked();
168 $customerSecure = $this->customerRegistry->retrieveSecureData(
$customerId);
169 $hash = $customerSecure->getPasswordHash();
170 if (!$this->encryptor->validateHash($password, $hash)) {
186 private function getCustomerAuthUpdate()
188 if ($this->customerAuthUpdate ===
null) {
189 $this->customerAuthUpdate =
192 return $this->customerAuthUpdate;
elseif(isset( $params[ 'redirect_parent']))
const LOCKOUT_THRESHOLD_PATH
__construct(CustomerRepositoryInterface $customerRepository, CustomerRegistry $customerRegistry, ConfigInterface $backendConfig, \Magento\Framework\Stdlib\DateTime $dateTime, Encryptor $encryptor)
authenticate($customerId, $password)
processAuthenticationFailure($customerId)