CustomerLoginSuccessObserver.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Customer\Observer;
  7. use Magento\Customer\Model\AuthenticationInterface;
  8. use Magento\Framework\Event\ObserverInterface;
  9. /**
  10. * Class CustomerLoginSuccessObserver
  11. */
  12. class CustomerLoginSuccessObserver implements ObserverInterface
  13. {
  14. /**
  15. * Authentication
  16. *
  17. * @var AuthenticationInterface
  18. */
  19. protected $authentication;
  20. /**
  21. * @param AuthenticationInterface $authentication
  22. */
  23. public function __construct(
  24. AuthenticationInterface $authentication
  25. ) {
  26. $this->authentication = $authentication;
  27. }
  28. /**
  29. * Unlock customer on success login attempt.
  30. * @param \Magento\Framework\Event\Observer $observer
  31. * @return $this
  32. */
  33. public function execute(\Magento\Framework\Event\Observer $observer)
  34. {
  35. /** @var \Magento\Customer\Model\Customer $customer */
  36. $customer = $observer->getEvent()->getData('model');
  37. $this->authentication->unlock($customer->getId());
  38. return $this;
  39. }
  40. }