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