Skip to content

Commit

Permalink
🔃 [Magento Community Engineering] Community Contributions - 2.4-develop
Browse files Browse the repository at this point in the history
Accepted Community Pull Requests:
 - #26769: Fix return type in ResetAttemptForFrontendObserver and ResetAttemptForBackendObserver (by @karyna-tsymbal-atwix)
 - #26712: Unit test for \Magento\Captcha\Observer\CheckUserForgotPasswordBackendObserver (by @karyna-tsymbal-atwix)
 - #26857: Issue/26843: Fix es_US Spanish (United States ) Locale is not support� (by @vincent-le89)
 - #26839: Unit test for \Magento\MediaGallery\Plugin\Wysiwyg\Images\Storage (by @karyna-tsymbal-atwix)
 - #26844: Unit Tests for observers from Magento_Reports (by @karyna-tsymbal-atwix)
 - #26688: Use '===' operator to check if file was written. (by @vovayatsyuk)
 - #26846: magento/magento2#: GraphQL. setPaymentMethodOnCart mutation. Extend list of required parameters for testSetPaymentMethodWithoutRequiredParameters (by @atwixfirster)
 - #24612: Fix for the issue #24547 Magento\Customer\Model\Account\Redirect::setRedirectCookie() not properly working (by @sashas777)
 - #26768: Marginal space validation (by @ajithkumar-maragathavel)
 - #26835: Unit test for Magento\Downloadable\Model\Sample\DeleteHandler (by @karyna-tsymbal-atwix)
 - #26398: Move additional dependencies from private getters to constructor - Magento_Captcha (by @Bartlomiejsz)
 - #26659: [26054-Do not duplicate SEO meta data when duplicating a product] (by @dasharath-wagento)
 - #26317: #26314: fixed logic for updating map price for selected swatch (by @sergiy-v)


Fixed GitHub Issues:
 - #26843: es_US Spanish (United States ) Locale is not supported in Magento 2.3.4 (reported by @karthi6116) has been fixed in #26857 by @vincent-le89 in 2.4-develop branch
   Related commits:
     1. bab4fb6
     2. fb71138
     3. 2b1bce5

 - #24547: Magento\Customer\Model\Account\Redirect::setRedirectCookie() not properly working (reported by @nikoskip) has been fixed in #24612 by @sashas777 in 2.4-develop branch
   Related commits:
     1. a15f335
     2. 664056f
     3. 5188efd
     4. 3cf8f22
     5. 7597003
     6. 9413892
     7. 9f2bbc2
     8. bfa636f
     9. 6446aed
     10. 162ca60
     11. 16da706
     12. 2c24ef9
     13. a514803
     14. bfeadd7
     15. cd5ef3c
     16. dc416a9
     17. 41ce59e
     18. f021f1e
     19. 511e16a

 - #26054: Do not duplicate SEO meta data when duplicating a product (reported by @Zyles) has been fixed in #26659 by @dasharath-wagento in 2.4-develop branch
   Related commits:
     1. 1f96b87
     2. 89b0a9d
     3. 99383fc
     4. 2d19477
     5. 5aea4ac
     6. dbf3924

 - #26240: Minimum Advertised Price doesn't change for selected swatch option for configurable product (reported by @sergiy-v) has been fixed in #26317 by @sergiy-v in 2.4-develop branch
   Related commits:
     1. b3abb06
     2. 9d9086f
     3. c12ca77
     4. 992e3d1
     5. df37523
     6. 824ef9f

 - #26314: Minimum Advertised Prices duplicates for all configurable products with price from selected swatch (reported by @sergiy-v) has been fixed in #26317 by @sergiy-v in 2.4-develop branch
   Related commits:
     1. b3abb06
     2. 9d9086f
     3. c12ca77
     4. 992e3d1
     5. df37523
     6. 824ef9f
  • Loading branch information
magento-engcom-team authored Feb 20, 2020
2 parents cde4f67 + abc8d10 commit a1fad2b
Show file tree
Hide file tree
Showing 29 changed files with 1,593 additions and 328 deletions.
65 changes: 30 additions & 35 deletions app/code/Magento/Captcha/Observer/CheckContactUsFormObserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,41 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\Captcha\Observer;

use Magento\Captcha\Helper\Data;
use Magento\Framework\App\Action\Action;
use Magento\Framework\App\ActionFlag;
use Magento\Framework\App\Response\RedirectInterface;
use Magento\Framework\Event\Observer;
use Magento\Framework\Event\ObserverInterface;
use Magento\Framework\App\Request\DataPersistorInterface;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\Message\ManagerInterface;

/**
* Class CheckContactUsFormObserver
* Check captcha on contact us form submit observer.
*/
class CheckContactUsFormObserver implements ObserverInterface
{
/**
* @var \Magento\Captcha\Helper\Data
* @var Data
*/
protected $_helper;

/**
* @var \Magento\Framework\App\ActionFlag
* @var ActionFlag
*/
protected $_actionFlag;

/**
* @var \Magento\Framework\Message\ManagerInterface
* @var ManagerInterface
*/
protected $messageManager;

/**
* @var \Magento\Framework\App\Response\RedirectInterface
* @var RedirectInterface
*/
protected $redirect;

Expand All @@ -45,60 +52,48 @@ class CheckContactUsFormObserver implements ObserverInterface
private $dataPersistor;

/**
* @param \Magento\Captcha\Helper\Data $helper
* @param \Magento\Framework\App\ActionFlag $actionFlag
* @param \Magento\Framework\Message\ManagerInterface $messageManager
* @param \Magento\Framework\App\Response\RedirectInterface $redirect
* @param Data $helper
* @param ActionFlag $actionFlag
* @param ManagerInterface $messageManager
* @param RedirectInterface $redirect
* @param CaptchaStringResolver $captchaStringResolver
* @param DataPersistorInterface $dataPersistor
*/
public function __construct(
\Magento\Captcha\Helper\Data $helper,
\Magento\Framework\App\ActionFlag $actionFlag,
\Magento\Framework\Message\ManagerInterface $messageManager,
\Magento\Framework\App\Response\RedirectInterface $redirect,
CaptchaStringResolver $captchaStringResolver
Data $helper,
ActionFlag $actionFlag,
ManagerInterface $messageManager,
RedirectInterface $redirect,
CaptchaStringResolver $captchaStringResolver,
DataPersistorInterface $dataPersistor
) {
$this->_helper = $helper;
$this->_actionFlag = $actionFlag;
$this->messageManager = $messageManager;
$this->redirect = $redirect;
$this->captchaStringResolver = $captchaStringResolver;
$this->dataPersistor = $dataPersistor;
}

/**
* Check CAPTCHA on Contact Us page
*
* @param \Magento\Framework\Event\Observer $observer
* @param Observer $observer
* @return void
*/
public function execute(\Magento\Framework\Event\Observer $observer)
public function execute(Observer $observer)
{
$formId = 'contact_us';
$captcha = $this->_helper->getCaptcha($formId);
if ($captcha->isRequired()) {
/** @var \Magento\Framework\App\Action\Action $controller */
/** @var Action $controller */
$controller = $observer->getControllerAction();
if (!$captcha->isCorrect($this->captchaStringResolver->resolve($controller->getRequest(), $formId))) {
$this->messageManager->addErrorMessage(__('Incorrect CAPTCHA.'));
$this->getDataPersistor()->set($formId, $controller->getRequest()->getPostValue());
$this->_actionFlag->set('', \Magento\Framework\App\Action\Action::FLAG_NO_DISPATCH, true);
$this->dataPersistor->set($formId, $controller->getRequest()->getPostValue());
$this->_actionFlag->set('', Action::FLAG_NO_DISPATCH, true);
$this->redirect->redirect($controller->getResponse(), 'contact/index/index');
}
}
}

/**
* Get Data Persistor
*
* @return DataPersistorInterface
*/
private function getDataPersistor()
{
if ($this->dataPersistor === null) {
$this->dataPersistor = ObjectManager::getInstance()
->get(DataPersistorInterface::class);
}

return $this->dataPersistor;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,39 @@
*/
namespace Magento\Captcha\Observer;

use Magento\Captcha\Model\ResourceModel\Log;
use Magento\Captcha\Model\ResourceModel\LogFactory;
use Magento\Framework\Event\Observer;
use Magento\Framework\Event\ObserverInterface;
use Magento\Framework\Exception\LocalizedException;

/**
* Reset captcha attempts for Backend
*/
class ResetAttemptForBackendObserver implements ObserverInterface
{
/**
* @var \Magento\Captcha\Model\ResourceModel\LogFactory
* @var LogFactory
*/
public $resLogFactory;

/**
* @param \Magento\Captcha\Model\ResourceModel\LogFactory $resLogFactory
* @param LogFactory $resLogFactory
*/
public function __construct(
\Magento\Captcha\Model\ResourceModel\LogFactory $resLogFactory
LogFactory $resLogFactory
) {
$this->resLogFactory = $resLogFactory;
}

/**
* Reset Attempts For Backend
*
* @param \Magento\Framework\Event\Observer $observer
* @return \Magento\Captcha\Observer\ResetAttemptForBackendObserver
* @param Observer $observer
* @return Log
* @throws LocalizedException
*/
public function execute(\Magento\Framework\Event\Observer $observer)
public function execute(Observer $observer)
{
return $this->resLogFactory->create()->deleteUserAttempts($observer->getUser()->getUsername());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,42 @@
*/
namespace Magento\Captcha\Observer;

use Magento\Captcha\Model\ResourceModel\Log;
use Magento\Captcha\Model\ResourceModel\LogFactory;
use Magento\Customer\Model\Customer;
use Magento\Framework\Event\Observer;
use Magento\Framework\Event\ObserverInterface;
use Magento\Framework\Exception\LocalizedException;

/**
* Reset captcha attempts for Frontend
*/
class ResetAttemptForFrontendObserver implements ObserverInterface
{
/**
* @var \Magento\Captcha\Model\ResourceModel\LogFactory
* @var LogFactory
*/
public $resLogFactory;

/**
* @param \Magento\Captcha\Model\ResourceModel\LogFactory $resLogFactory
* @param LogFactory $resLogFactory
*/
public function __construct(
\Magento\Captcha\Model\ResourceModel\LogFactory $resLogFactory
LogFactory $resLogFactory
) {
$this->resLogFactory = $resLogFactory;
}

/**
* Reset Attempts For Frontend
*
* @param \Magento\Framework\Event\Observer $observer
* @return \Magento\Captcha\Observer\ResetAttemptForFrontendObserver
* @param Observer $observer
* @return Log
* @throws LocalizedException
*/
public function execute(\Magento\Framework\Event\Observer $observer)
public function execute(Observer $observer)
{
/** @var \Magento\Customer\Model\Customer $model */
/** @var Customer $model */
$model = $observer->getModel();

return $this->resLogFactory->create()->deleteUserAttempts($model->getEmail());
Expand Down
Loading

0 comments on commit a1fad2b

Please sign in to comment.