79 $this->_actionFlag = $actionFlag;
81 $this->_session = $customerSession;
91 private function getCustomerRepository()
95 return \Magento\Framework\App\ObjectManager::getInstance()->get(
108 private function getAuthentication()
111 if (!($this->authentication instanceof AuthenticationInterface)) {
112 return \Magento\Framework\App\ObjectManager::getInstance()->get(
113 AuthenticationInterface::class
129 $formId =
'user_login';
130 $captchaModel = $this->_helper->getCaptcha($formId);
132 $loginParams =
$controller->getRequest()->getPost(
'login');
133 $login = (is_array($loginParams) && array_key_exists(
'username', $loginParams))
134 ? $loginParams[
'username']
136 if ($captchaModel->isRequired($login)) {
137 $word = $this->captchaStringResolver->resolve(
$controller->getRequest(), $formId);
138 if (!$captchaModel->isCorrect($word)) {
140 $customer = $this->getCustomerRepository()->get($login);
141 $this->getAuthentication()->processAuthenticationFailure(
$customer->getId());
145 $this->messageManager->addError(
__(
'Incorrect CAPTCHA'));
146 $this->_actionFlag->set(
'', \
Magento\Framework\
App\Action\Action::FLAG_NO_DISPATCH,
true);
147 $this->_session->setUsername($login);
148 $beforeUrl = $this->_session->getBeforeAuthUrl();
149 $url = $beforeUrl ? $beforeUrl : $this->_customerUrl->getLoginUrl();
153 $captchaModel->logAttempt($login);
__construct(\Magento\Captcha\Helper\Data $helper, \Magento\Framework\App\ActionFlag $actionFlag, \Magento\Framework\Message\ManagerInterface $messageManager, \Magento\Framework\Session\SessionManagerInterface $customerSession, CaptchaStringResolver $captchaStringResolver, \Magento\Customer\Model\Url $customerUrl)
execute(\Magento\Framework\Event\Observer $observer)