Class Authentication @SuppressWarnings(PHPMD.CouplingBetweenObjects)
Definition at line 20 of file Authentication.php.
◆ __construct()
- Parameters
-
CustomerRepositoryInterface | $customerRepository | |
CustomerRegistry | $customerRegistry | |
ConfigInterface | $backendConfig | |
\Magento\Framework\Stdlib\DateTime | $dateTime | |
Encryptor | $encryptor | |
Definition at line 71 of file Authentication.php.
◆ authenticate()
authenticate |
( |
|
$customerId, |
|
|
|
$password |
|
) |
| |
{Authenticate customer
- Parameters
-
int | $customerId | |
string | $password | |
- Returns
- boolean
- Exceptions
-
InvalidEmailOrPasswordException | |
UserLockedException | |
}
Implements AuthenticationInterface.
Definition at line 166 of file Authentication.php.
168 $customerSecure = $this->customerRegistry->retrieveSecureData(
$customerId);
169 $hash = $customerSecure->getPasswordHash();
170 if (!$this->encryptor->validateHash($password, $hash)) {
173 throw new UserLockedException(
__(
'The account is locked.'));
175 throw new InvalidEmailOrPasswordException(
__(
'Invalid login or password.'));
processAuthenticationFailure($customerId)
◆ getLockThreshold()
Get lock threshold
- Returns
- int
Definition at line 139 of file Authentication.php.
141 return $this->backendConfig->getValue(self::LOCKOUT_THRESHOLD_PATH) * 60;
◆ getMaxFailures()
Get max failures
- Returns
- int
Definition at line 149 of file Authentication.php.
151 return $this->backendConfig->getValue(self::MAX_FAILURES_PATH);
◆ isLocked()
◆ processAuthenticationFailure()
processAuthenticationFailure |
( |
|
$customerId | ) |
|
{Process customer authentication failure
- Parameters
-
- Returns
- void
}
Implements AuthenticationInterface.
Definition at line 88 of file Authentication.php.
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);
elseif(isset( $params[ 'redirect_parent']))
◆ unlock()
{Unlock customer
- Parameters
-
- Returns
- void
}
Implements AuthenticationInterface.
Definition at line 125 of file Authentication.php.
127 $customerSecure = $this->customerRegistry->retrieveSecureData(
$customerId);
128 $customerSecure->setFailuresNum(0);
129 $customerSecure->setFirstFailure(
null);
130 $customerSecure->setLockExpires(
null);
131 $this->getCustomerAuthUpdate()->saveAuth(
$customerId);
◆ $backendConfig
◆ $customerRegistry
◆ $customerRepository
◆ $dateTime
◆ $encryptor
◆ LOCKOUT_THRESHOLD_PATH
const LOCKOUT_THRESHOLD_PATH = 'customer/password/lockout_threshold' |
◆ MAX_FAILURES_PATH
const MAX_FAILURES_PATH = 'customer/password/lockout_failures' |
Configuration path to customer max login failures number
Definition at line 30 of file Authentication.php.
The documentation for this class was generated from the following file: