/** * {@inheritdoc} */ public function incrementFailuresCount($userName, $userType) { $date = (new \DateTime())->setTimestamp($this->dateTime->gmtTimestamp()); $date->add(new \DateInterval('PT' . $this->requestLogConfig->getLockTimeout() . 'S')); $dateTime = $date->format(\Magento\Framework\Stdlib\DateTime::DATETIME_PHP_FORMAT); $this->getConnection()->insertOnDuplicate($this->getMainTable(), ['user_name' => $userName, 'user_type' => $userType, 'failures_count' => 1, 'lock_expires_at' => $dateTime], ['failures_count' => new \Zend_Db_Expr('failures_count+1'), 'lock_expires_at' => new \Zend_Db_Expr("'" . $dateTime . "'")]); }
/** * Throw exception if user account is currently locked because of too many failed authentication attempts. * * @param string $userName * @param int $userType * @return void * @throws AuthenticationException */ public function throttle($userName, $userType) { $count = $this->requestLogReader->getFailuresCount($userName, $userType); if ($count >= $this->requestLogConfig->getMaxFailuresCount()) { throw new AuthenticationException(__('You did not sign in correctly or your account is temporarily disabled.')); } }