11<?php
22/**
3- * Copyright © Magento, Inc. All rights reserved.
4- * See COPYING.txt for license details .
3+ * Copyright 2016 Adobe
4+ * All Rights Reserved .
55 */
66namespace Magento \Customer \Model ;
77
88use Magento \Customer \Api \CustomerRepositoryInterface ;
99use Magento \Customer \Model \ResourceModel \CustomerRepository ;
10- use Magento \Customer \Model \CustomerAuthUpdate ;
1110use Magento \Backend \App \ConfigInterface ;
11+ use Magento \Framework \App \ObjectManager ;
1212use Magento \Framework \Encryption \EncryptorInterface as Encryptor ;
1313use Magento \Framework \Exception \InvalidEmailOrPasswordException ;
1414use Magento \Framework \Exception \State \UserLockedException ;
1515
1616/**
17- * Class Authentication
17+ * Class Authentication model
1818 * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1919 */
2020class Authentication implements AuthenticationInterface
2121{
2222 /**
2323 * Configuration path to customer lockout threshold
2424 */
25- const LOCKOUT_THRESHOLD_PATH = 'customer/password/lockout_threshold ' ;
25+ public const LOCKOUT_THRESHOLD_PATH = 'customer/password/lockout_threshold ' ;
2626
2727 /**
2828 * Configuration path to customer max login failures number
2929 */
30- const MAX_FAILURES_PATH = 'customer/password/lockout_failures ' ;
30+ public const MAX_FAILURES_PATH = 'customer/password/lockout_failures ' ;
3131
3232 /**
3333 * @var CustomerRegistry
@@ -67,19 +67,22 @@ class Authentication implements AuthenticationInterface
6767 * @param ConfigInterface $backendConfig
6868 * @param \Magento\Framework\Stdlib\DateTime $dateTime
6969 * @param Encryptor $encryptor
70+ * @param CustomerAuthUpdate|null $customerAuthUpdate
7071 */
7172 public function __construct (
7273 CustomerRepositoryInterface $ customerRepository ,
7374 CustomerRegistry $ customerRegistry ,
7475 ConfigInterface $ backendConfig ,
7576 \Magento \Framework \Stdlib \DateTime $ dateTime ,
76- Encryptor $ encryptor
77+ Encryptor $ encryptor ,
78+ CustomerAuthUpdate $ customerAuthUpdate = null
7779 ) {
7880 $ this ->customerRepository = $ customerRepository ;
7981 $ this ->customerRegistry = $ customerRegistry ;
8082 $ this ->backendConfig = $ backendConfig ;
8183 $ this ->dateTime = $ dateTime ;
8284 $ this ->encryptor = $ encryptor ;
85+ $ this ->customerAuthUpdate = $ customerAuthUpdate ?: ObjectManager::getInstance ()->get (CustomerAuthUpdate::class);
8386 }
8487
8588 /**
@@ -116,7 +119,7 @@ public function processAuthenticationFailure($customerId)
116119 }
117120
118121 $ customerSecure ->setFailuresNum ($ failuresNum );
119- $ this ->getCustomerAuthUpdate () ->saveAuth ($ customerId );
122+ $ this ->customerAuthUpdate ->saveAuth ($ customerId );
120123 }
121124
122125 /**
@@ -128,7 +131,7 @@ public function unlock($customerId)
128131 $ customerSecure ->setFailuresNum (0 );
129132 $ customerSecure ->setFirstFailure (null );
130133 $ customerSecure ->setLockExpires (null );
131- $ this ->getCustomerAuthUpdate () ->saveAuth ($ customerId );
134+ $ this ->customerAuthUpdate ->saveAuth ($ customerId );
132135 }
133136
134137 /**
@@ -176,19 +179,4 @@ public function authenticate($customerId, $password)
176179 }
177180 return true ;
178181 }
179-
180- /**
181- * Get customer authentication update model
182- *
183- * @return \Magento\Customer\Model\CustomerAuthUpdate
184- * @deprecated 100.1.1
185- */
186- private function getCustomerAuthUpdate ()
187- {
188- if ($ this ->customerAuthUpdate === null ) {
189- $ this ->customerAuthUpdate =
190- \Magento \Framework \App \ObjectManager::getInstance ()->get (CustomerAuthUpdate::class);
191- }
192- return $ this ->customerAuthUpdate ;
193- }
194182}
0 commit comments