CustomerAuthUpdate.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Customer\Model;
  7. /**
  8. * Customer Authentication update model.
  9. */
  10. class CustomerAuthUpdate
  11. {
  12. /**
  13. * @var \Magento\Customer\Model\CustomerRegistry
  14. */
  15. protected $customerRegistry;
  16. /**
  17. * @var \Magento\Customer\Model\ResourceModel\Customer
  18. */
  19. protected $customerResourceModel;
  20. /**
  21. * @param \Magento\Customer\Model\CustomerRegistry $customerRegistry
  22. * @param \Magento\Customer\Model\ResourceModel\Customer $customerResourceModel
  23. */
  24. public function __construct(
  25. \Magento\Customer\Model\CustomerRegistry $customerRegistry,
  26. \Magento\Customer\Model\ResourceModel\Customer $customerResourceModel
  27. ) {
  28. $this->customerRegistry = $customerRegistry;
  29. $this->customerResourceModel = $customerResourceModel;
  30. }
  31. /**
  32. * Reset Authentication data for customer.
  33. *
  34. * @param int $customerId
  35. * @return $this
  36. */
  37. public function saveAuth($customerId)
  38. {
  39. $customerSecure = $this->customerRegistry->retrieveSecureData($customerId);
  40. $this->customerResourceModel->getConnection()->update(
  41. $this->customerResourceModel->getTable('customer_entity'),
  42. [
  43. 'failures_num' => $customerSecure->getData('failures_num'),
  44. 'first_failure' => $customerSecure->getData('first_failure'),
  45. 'lock_expires' => $customerSecure->getData('lock_expires'),
  46. ],
  47. $this->customerResourceModel->getConnection()->quoteInto('entity_id = ?', $customerId)
  48. );
  49. return $this;
  50. }
  51. }