diff --git a/vendor/magento/module-customer/Model/ForgotPasswordToken/GetCustomerByToken.php b/vendor/magento/module-customer/Model/ForgotPasswordToken/GetCustomerByToken.php
index 994bf7b40deb5..e91bab987e906 100644
--- a/vendor/magento/module-customer/Model/ForgotPasswordToken/GetCustomerByToken.php
+++ b/vendor/magento/module-customer/Model/ForgotPasswordToken/GetCustomerByToken.php
@@ -9,15 +9,19 @@
use Magento\Customer\Api\CustomerRepositoryInterface;
use Magento\Customer\Api\Data\CustomerInterface;
+use Magento\Customer\Model\ResourceModel\Customer\CollectionFactory;
use Magento\Framework\Api\SearchCriteriaBuilder;
+use Magento\Framework\App\ObjectManager;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Framework\Exception\State\ExpiredException;
use Magento\Framework\Phrase;
/**
* Get Customer By reset password token
+ *
* @SuppressWarnings(PHPMD.LongVariable)
* @deprecated Rp Tokens cannot be looked up directly
+ * @see not used anymore
*/
class GetCustomerByToken
{
@@ -32,17 +36,24 @@ class GetCustomerByToken
private $searchCriteriaBuilder;
/**
- * ForgotPassword constructor.
- *
+ * @var CollectionFactory
+ */
+ private $collectionFactory;
+
+ /**
* @param \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository
* @param \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder
+ * @param CollectionFactory|null $collectionFactory
*/
public function __construct(
CustomerRepositoryInterface $customerRepository,
- SearchCriteriaBuilder $searchCriteriaBuilder
+ SearchCriteriaBuilder $searchCriteriaBuilder,
+ ?CollectionFactory $collectionFactory = null
) {
$this->customerRepository = $customerRepository;
$this->searchCriteriaBuilder = $searchCriteriaBuilder;
+ $this->collectionFactory = $collectionFactory
+ ?? ObjectManager::getInstance()->get(CollectionFactory::class);
}
/**
@@ -53,38 +64,27 @@ public function __construct(
* @return \Magento\Customer\Api\Data\CustomerInterface
* @throws ExpiredException
* @throws NoSuchEntityException
- * @throws \Magento\Framework\Exception\LocalizedException
*/
public function execute(string $resetPasswordToken): CustomerInterface
{
- $this->searchCriteriaBuilder->addFilter(
- 'rp_token',
- $resetPasswordToken
- );
- $this->searchCriteriaBuilder->setPageSize(1);
- $found = $this->customerRepository->getList(
- $this->searchCriteriaBuilder->create()
- );
+ $collection = $this->collectionFactory->create();
+ $collection->addAttributeToFilter('rp_token', $resetPasswordToken);
+ $size = $collection->getSize();
- if ($found->getTotalCount() > 1) {
- //Failed to generated unique RP token
+ if ($size > 1) {
throw new ExpiredException(
new Phrase('Reset password token expired.')
);
}
- if ($found->getTotalCount() === 0) {
- //Customer with such token not found.
+ if ($size === 0) {
throw new NoSuchEntityException(
new Phrase(
'No such entity with rp_token = %value',
- [
- 'value' => $resetPasswordToken
- ]
+ ['value' => $resetPasswordToken]
)
);
}
- //Unique customer found.
- return $found->getItems()[0];
+ return $collection->getFirstItem();
}
}
diff --git a/vendor/magento/module-customer/Model/Plugin/CustomerRepository/RestrictedFieldsPlugin.php b/vendor/magento/module-customer/Model/Plugin/CustomerRepository/RestrictedFieldsPlugin.php
new file mode 100644
index 0000000000000..22b15905b4934
--- /dev/null
+++ b/vendor/magento/module-customer/Model/Plugin/CustomerRepository/RestrictedFieldsPlugin.php
@@ -0,0 +1,74 @@
+restrictedFields = $restrictedFields;
+ }
+
+ /**
+ * Check forbidden customer fields
+ *
+ * @param CustomerRepositoryInterface $subject
+ * @param SearchCriteriaInterface $searchCriteria
+ * @return array
+ * @throws InputException
+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)
+ */
+ public function beforeGetList(
+ CustomerRepositoryInterface $subject,
+ SearchCriteriaInterface $searchCriteria
+ ): array {
+ foreach ($searchCriteria->getFilterGroups() as $filterGroup) {
+ foreach ($filterGroup->getFilters() as $filter) {
+ if ($this->isRestricted($filter->getField())) {
+ throw new InputException(
+ __('The search criteria filter field is invalid.')
+ );
+ }
+ }
+ }
+ foreach ($searchCriteria->getSortOrders() ?? [] as $sortOrder) {
+ if ($this->isRestricted($sortOrder->getField())) {
+ throw new InputException(
+ __('The search criteria sort field is invalid.')
+ );
+ }
+ }
+ return [$searchCriteria];
+ }
+
+ /**
+ * Check if the given field name matches a restricted field
+ *
+ * @param string|null $field
+ * @return bool
+ */
+ private function isRestricted(?string $field): bool
+ {
+ return $field !== null && in_array(strtolower($field), $this->restrictedFields, true);
+ }
+}
diff --git a/vendor/magento/module-customer/etc/di.xml b/vendor/magento/module-customer/etc/di.xml
index 120a8dda8aece..c9dc21a0faa06 100644
--- a/vendor/magento/module-customer/etc/di.xml
+++ b/vendor/magento/module-customer/etc/di.xml
@@ -85,6 +85,15 @@
SessionValidator
+
+
+
+ - password_hash
+ - rp_token
+ - confirmation
+
+
+
Magento\Customer\Model\Address\Config\Proxy
diff --git a/vendor/magento/module-customer/etc/graphql/di.xml b/vendor/magento/module-customer/etc/graphql/di.xml
index e5ed4078b4a04..89095704f51e8 100644
--- a/vendor/magento/module-customer/etc/graphql/di.xml
+++ b/vendor/magento/module-customer/etc/graphql/di.xml
@@ -16,4 +16,7 @@
+
+
+
diff --git a/vendor/magento/module-customer/etc/webapi_rest/di.xml b/vendor/magento/module-customer/etc/webapi_rest/di.xml
index 18627b68320ed..f649cb6732b94 100644
--- a/vendor/magento/module-customer/etc/webapi_rest/di.xml
+++ b/vendor/magento/module-customer/etc/webapi_rest/di.xml
@@ -21,6 +21,7 @@
+
diff --git a/vendor/magento/module-customer/etc/webapi_soap/di.xml b/vendor/magento/module-customer/etc/webapi_soap/di.xml
index cb0b1ce58a594..2f9c0cc786995 100644
--- a/vendor/magento/module-customer/etc/webapi_soap/di.xml
+++ b/vendor/magento/module-customer/etc/webapi_soap/di.xml
@@ -18,6 +18,9 @@
+
+
+
diff --git a/vendor/magento/module-customer/i18n/en_US.csv b/vendor/magento/module-customer/i18n/en_US.csv
index a00bb04523ccc..581114c2dc4b5 100644
--- a/vendor/magento/module-customer/i18n/en_US.csv
+++ b/vendor/magento/module-customer/i18n/en_US.csv
@@ -546,3 +546,5 @@ Addresses,Addresses
"The specified customer group id does not exist.","The specified customer group id does not exist."
"Something went wrong while logging out customer.","Something went wrong while logging out customer."
"Address not found.","Address not found."
+"The search criteria filter field is invalid.","The search criteria filter field is invalid."
+"The search criteria sort field is invalid.","The search criteria sort field is invalid."