Skip to content

Commit ec7e32a

Browse files
Merge pull request #9309 from adobe-commerce-tier-4/PR_13_OCT_2024
[Support Tier-4 odubovyk] 10-13-2024 Regular delivery of bugfixes and improvements
2 parents 9c48c55 + f4a9461 commit ec7e32a

File tree

32 files changed

+916
-155
lines changed

32 files changed

+916
-155
lines changed

app/code/Magento/Customer/Model/Authentication.php

+12-24
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
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
*/
66
namespace Magento\Customer\Model;
77

88
use Magento\Customer\Api\CustomerRepositoryInterface;
99
use Magento\Customer\Model\ResourceModel\CustomerRepository;
10-
use Magento\Customer\Model\CustomerAuthUpdate;
1110
use Magento\Backend\App\ConfigInterface;
11+
use Magento\Framework\App\ObjectManager;
1212
use Magento\Framework\Encryption\EncryptorInterface as Encryptor;
1313
use Magento\Framework\Exception\InvalidEmailOrPasswordException;
1414
use Magento\Framework\Exception\State\UserLockedException;
1515

1616
/**
17-
* Class Authentication
17+
* Class Authentication model
1818
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1919
*/
2020
class 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
}

app/code/Magento/Customer/Model/Customer.php

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2011 Adobe
4+
* All Rights Reserved.
55
*/
66

77
namespace Magento\Customer\Model;
@@ -1415,5 +1415,8 @@ public function getPassword()
14151415
public function _resetState(): void
14161416
{
14171417
$this->_errors = [];
1418+
$this->_origData = null;
1419+
$this->storedData = [];
1420+
$this->_data = [];
14181421
}
14191422
}

app/code/Magento/Customer/Model/CustomerAuthUpdate.php

+11-12
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
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
*/
66

77
namespace Magento\Customer\Model;
88

99
use Magento\Customer\Model\ResourceModel\Customer as CustomerResourceModel;
10-
use Magento\Framework\App\ObjectManager;
1110
use Magento\Framework\Exception\NoSuchEntityException;
1211

1312
/**
@@ -26,23 +25,23 @@ class CustomerAuthUpdate
2625
protected $customerResourceModel;
2726

2827
/**
29-
* @var Customer
28+
* @var CustomerFactory
3029
*/
31-
private $customerModel;
30+
private $customerFactory;
3231

3332
/**
3433
* @param CustomerRegistry $customerRegistry
3534
* @param CustomerResourceModel $customerResourceModel
36-
* @param Customer|null $customerModel
35+
* @param CustomerFactory $customerFactory
3736
*/
3837
public function __construct(
3938
CustomerRegistry $customerRegistry,
4039
CustomerResourceModel $customerResourceModel,
41-
Customer $customerModel = null
40+
CustomerFactory $customerFactory
4241
) {
4342
$this->customerRegistry = $customerRegistry;
4443
$this->customerResourceModel = $customerResourceModel;
45-
$this->customerModel = $customerModel ?: ObjectManager::getInstance()->get(Customer::class);
44+
$this->customerFactory = $customerFactory;
4645
}
4746

4847
/**
@@ -55,9 +54,9 @@ public function __construct(
5554
public function saveAuth($customerId)
5655
{
5756
$customerSecure = $this->customerRegistry->retrieveSecureData($customerId);
58-
59-
$this->customerResourceModel->load($this->customerModel, $customerId);
60-
$currentLockExpiresVal = $this->customerModel->getData('lock_expires');
57+
$customerModel = $this->customerFactory->create();
58+
$this->customerResourceModel->load($customerModel, $customerId);
59+
$currentLockExpiresVal = $customerModel->getData('lock_expires');
6160
$newLockExpiresVal = $customerSecure->getData('lock_expires');
6261

6362
$this->customerResourceModel->getConnection()->update(
@@ -71,7 +70,7 @@ public function saveAuth($customerId)
7170
);
7271

7372
if ($currentLockExpiresVal !== $newLockExpiresVal) {
74-
$this->customerModel->reindex();
73+
$customerModel->reindex();
7574
}
7675

7776
return $this;

app/code/Magento/Customer/Test/Unit/Model/CustomerAuthUpdateTest.php

+14-8
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
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
*/
66
declare(strict_types=1);
77

88
namespace Magento\Customer\Test\Unit\Model;
99

1010
use Magento\Customer\Model\Customer as CustomerModel;
11+
use Magento\Customer\Model\CustomerFactory;
1112
use Magento\Customer\Model\CustomerAuthUpdate;
1213
use Magento\Customer\Model\CustomerRegistry;
1314
use Magento\Customer\Model\Data\CustomerSecure;
@@ -36,9 +37,9 @@ class CustomerAuthUpdateTest extends TestCase
3637
protected $customerResourceModel;
3738

3839
/**
39-
* @var CustomerModel|MockObject
40+
* @var CustomerFactory|MockObject
4041
*/
41-
protected $customerModel;
42+
protected $customerFactory;
4243

4344
/**
4445
* @var ObjectManager
@@ -56,15 +57,15 @@ protected function setUp(): void
5657
$this->createMock(CustomerRegistry::class);
5758
$this->customerResourceModel =
5859
$this->createMock(CustomerResourceModel::class);
59-
$this->customerModel =
60-
$this->createMock(CustomerModel::class);
60+
$this->customerFactory =
61+
$this->createMock(CustomerFactory::class);
6162

6263
$this->model = $this->objectManager->getObject(
6364
CustomerAuthUpdate::class,
6465
[
6566
'customerRegistry' => $this->customerRegistry,
6667
'customerResourceModel' => $this->customerResourceModel,
67-
'customerModel' => $this->customerModel
68+
'customerFactory' => $this->customerFactory
6869
]
6970
);
7071
}
@@ -115,9 +116,14 @@ public function testSaveAuth()
115116
$customerId
116117
);
117118

118-
$this->customerModel->expects($this->once())
119+
$customerModel = $this->createMock(CustomerModel::class);
120+
$customerModel->expects($this->once())
119121
->method('reindex');
120122

123+
$this->customerFactory->expects($this->once())
124+
->method('create')
125+
->willReturn($customerModel);
126+
121127
$this->model->saveAuth($customerId);
122128
}
123129
}
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
<?xml version="1.0"?>
22
<!--
33
/**
4-
* Copyright © Magento, Inc. All rights reserved.
5-
* See COPYING.txt for license details.
4+
* Copyright 2021 Adobe
5+
* All Rights Reserved.
66
*/
77
-->
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
99
xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
1010
<event name="customer_login">
1111
<observer name="customer_log_login" instance="Magento\Customer\Observer\LogLastLoginAtObserver" />
1212
</event>
13+
<event name="customer_customer_authenticated">
14+
<observer name="customer_unlock" instance="Magento\Customer\Observer\CustomerLoginSuccessObserver" />
15+
</event>
1316
</config>

app/code/Magento/CustomerImportExport/Model/Import/Address.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2012 Adobe
4+
* All Rights Reserved.
55
*/
66

77
namespace Magento\CustomerImportExport\Model\Import;
88

9-
use Magento\Customer\Model\ResourceModel\Address\Attribute\Source\CountryWithWebsites as CountryWithWebsitesSource;
9+
use Magento\CustomerImportExport\Model\Import\CountryWithWebsites as CountryWithWebsitesSource;
1010
use Magento\Eav\Model\Entity\Attribute\AbstractAttribute;
1111
use Magento\Framework\App\ObjectManager;
1212
use Magento\ImportExport\Model\Import\ErrorProcessing\ProcessingErrorAggregatorInterface;
@@ -365,7 +365,7 @@ public function getAttributeOptions(AbstractAttribute $attribute, array $indexAt
365365
if ($attribute->getAttributeCode() === 'country_id') {
366366
//If we want to get available options for country field then we have to use alternative source
367367
// to get actual data for each website.
368-
$options = $this->countryWithWebsites->getAllOptions();
368+
$options = $this->countryWithWebsites->getCountiesPerWebsite();
369369
//Available country options now will be sorted by websites.
370370
$code = $attribute->getAttributeCode();
371371
$websiteOptions = [Store::DEFAULT_STORE_ID => $standardOptions];

0 commit comments

Comments
 (0)