Skip to content

Commit 293cd41

Browse files
authored
Merge pull request #5317 from magento-tsg-csl3/2.4-develop-pr13
[TSG-CSL3] For 2.4 (pr13)
2 parents 9e9703a + 3c84234 commit 293cd41

File tree

16 files changed

+584
-113
lines changed

16 files changed

+584
-113
lines changed

app/code/Magento/Braintree/view/frontend/web/js/view/payment/3d-secure.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ define([
117117
options.bin = context.paymentPayload.details.bin;
118118
}
119119

120-
if (shippingAddress) {
120+
if (shippingAddress && this.isValidShippingAddress(shippingAddress)) {
121121
options.additionalInformation = {
122122
shippingGivenName: shippingAddress.firstname,
123123
shippingSurname: shippingAddress.lastname,
@@ -206,6 +206,25 @@ define([
206206
}
207207

208208
return false;
209+
},
210+
211+
/**
212+
* Validate shipping address
213+
*
214+
* @param {Object} shippingAddress
215+
* @return {Boolean}
216+
*/
217+
isValidShippingAddress: function (shippingAddress) {
218+
var isValid = false;
219+
220+
// check that required fields are not empty
221+
if (shippingAddress.firstname && shippingAddress.lastname && shippingAddress.telephone &&
222+
shippingAddress.street && shippingAddress.city && shippingAddress.regionCode &&
223+
shippingAddress.postcode && shippingAddress.countryId) {
224+
isValid = true;
225+
}
226+
227+
return isValid;
209228
}
210229
};
211230
});

app/code/Magento/Braintree/view/frontend/web/js/view/payment/method-renderer/cc-form.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ define(
9191
})
9292
.then(function (hostedFieldsInstance) {
9393
self.hostedFieldsInstance = hostedFieldsInstance;
94-
self.isPlaceOrderActionAllowed(true);
94+
self.isPlaceOrderActionAllowed(false);
9595
self.initFormValidationEvents(hostedFieldsInstance);
9696

9797
return self.hostedFieldsInstance;

app/code/Magento/Catalog/Test/Mftf/Test/CheckTierPricingOfProductsTest.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
<createData entity="Simple_US_Customer" stepKey="customer"/>
3737
<!--Login as admin-->
3838
<actionGroup ref="LoginAsAdmin" stepKey="LoginAsAdmin"/>
39+
<createData entity="CustomerAccountSharingGlobal" stepKey="setConfigCustomerAccountToGlobal"/>
3940
</before>
4041

4142
<!--Create website, Sore adn Store View-->
@@ -328,6 +329,7 @@
328329
<actionGroup ref="AdminDeleteWebsiteActionGroup" stepKey="DeleteWebsite">
329330
<argument name="websiteName" value="secondWebsite"/>
330331
</actionGroup>
332+
<createData entity="CustomerAccountSharingDefault" stepKey="setConfigCustomerAccountDefault"/>
331333
<actionGroup ref="logout" stepKey="logout"/>
332334

333335
<!--Do reindex and flush cache-->

app/code/Magento/Cms/Model/ResourceModel/Block.php

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -185,13 +185,9 @@ public function getIsUniqueBlockToStores(AbstractModel $object)
185185
$entityMetadata = $this->metadataPool->getMetadata(BlockInterface::class);
186186
$linkField = $entityMetadata->getLinkField();
187187

188-
$stores = (array)$object->getData('store_id');
189-
$isDefaultStore = $this->_storeManager->isSingleStoreMode()
190-
|| array_search(Store::DEFAULT_STORE_ID, $stores) !== false;
191-
192-
if (!$isDefaultStore) {
193-
$stores[] = Store::DEFAULT_STORE_ID;
194-
}
188+
$stores = $this->_storeManager->isSingleStoreMode()
189+
? [Store::DEFAULT_STORE_ID]
190+
: (array)$object->getData('store_id');
195191

196192
$select = $this->getConnection()->select()
197193
->from(['cb' => $this->getMainTable()])
@@ -200,11 +196,8 @@ public function getIsUniqueBlockToStores(AbstractModel $object)
200196
'cb.' . $linkField . ' = cbs.' . $linkField,
201197
[]
202198
)
203-
->where('cb.identifier = ? ', $object->getData('identifier'));
204-
205-
if (!$isDefaultStore) {
206-
$select->where('cbs.store_id IN (?)', $stores);
207-
}
199+
->where('cb.identifier = ? ', $object->getData('identifier'))
200+
->where('cbs.store_id IN (?)', $stores);
208201

209202
if ($object->getId()) {
210203
$select->where('cb.' . $entityMetadata->getIdentifierField() . ' <> ?', $object->getId());

app/code/Magento/Cms/Test/Mftf/Test/CheckStaticBlocksTest.xml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,23 @@
5656
<seeInCurrentUrl url="cms/block/new" stepKey="VerifyNewBlockPageIsOpened1"/>
5757
<!--Add new BLock with the same data-->
5858
<actionGroup ref="FillOutBlockContent" stepKey="FillOutBlockContent1"/>
59-
<selectOption selector="{{BlockNewPageBasicFieldsSection.storeView}}" userInput="Default Store View" stepKey="selectDefaultStoreView" />
60-
<selectOption selector="{{BlockNewPageBasicFieldsSection.storeView}}" userInput="{{customStore.name}}" stepKey="selectSecondStoreView1" />
6159
<click selector="{{BlockNewPagePageActionsSection.saveBlock}}" stepKey="ClickToSaveBlock1"/>
6260
<waitForPageLoad stepKey="waitForPageLoad6"/>
6361
<!--Verify that corresponding message is displayed-->
6462
<see userInput="A block identifier with the same properties already exists in the selected store." stepKey="VerifyBlockIsSaved1"/>
63+
<!--Click to go back and add new block-->
64+
<click selector="{{BlockNewPagePageActionsSection.back}}" stepKey="ClickToGoBack1"/>
65+
<waitForPageLoad stepKey="waitForPageLoad7"/>
66+
<click selector="{{BlockPageActionsSection.addNewBlock}}" stepKey="ClickToAddNewBlock2"/>
67+
<waitForPageLoad stepKey="waitForPageLoad8"/>
68+
<seeInCurrentUrl url="cms/block/new" stepKey="VerifyNewBlockPageIsOpened2"/>
69+
<!--Add new BLock with the same data for another store view-->
70+
<actionGroup ref="FillOutBlockContent" stepKey="FillOutBlockContent2"/>
71+
<selectOption selector="{{BlockNewPageBasicFieldsSection.storeView}}" userInput="Default Store View" stepKey="selectDefaultStoreView" />
72+
<selectOption selector="{{BlockNewPageBasicFieldsSection.storeView}}" userInput="{{customStore.name}}" stepKey="selectSecondStoreView1" />
73+
<click selector="{{BlockNewPagePageActionsSection.saveBlock}}" stepKey="ClickToSaveBlock2"/>
74+
<waitForPageLoad stepKey="waitForPageLoad9"/>
75+
<see userInput="You saved the block." stepKey="VerifyBlockIsSaved2"/>
6576

6677
<after>
6778
<actionGroup ref="AdminDeleteWebsiteActionGroup" stepKey="DeleteWebsite">

app/code/Magento/Customer/Controller/Adminhtml/Index/Save.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,8 +348,14 @@ public function execute()
348348
['customer' => $customer, 'request' => $this->getRequest()]
349349
);
350350

351-
if (isset($customerData['sendemail_store_id'])) {
351+
if (isset($customerData['sendemail_store_id']) && $customerData['sendemail_store_id'] !== false) {
352352
$customer->setStoreId($customerData['sendemail_store_id']);
353+
try {
354+
$this->customerAccountManagement->validateCustomerStoreIdByWebsiteId($customer);
355+
} catch (LocalizedException $exception) {
356+
throw new LocalizedException(__("The Store View selected for sending Welcome email from".
357+
" is not related to the customer's associated website."));
358+
}
353359
}
354360

355361
// Save customer

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

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -872,7 +872,6 @@ public function createAccountWithPasswordHash(CustomerInterface $customer, $hash
872872
if ($customer->getId()) {
873873
$customer = $this->customerRepository->get($customer->getEmail());
874874
$websiteId = $customer->getWebsiteId();
875-
876875
if ($this->isCustomerInStore($websiteId, $customer->getStoreId())) {
877876
throw new InputException(__('This customer already exists in this store.'));
878877
}
@@ -896,13 +895,10 @@ public function createAccountWithPasswordHash(CustomerInterface $customer, $hash
896895
$customer->setWebsiteId($websiteId);
897896
}
898897

898+
$this->validateCustomerStoreIdByWebsiteId($customer);
899+
899900
// Update 'created_in' value with actual store name
900901
if ($customer->getId() === null) {
901-
$websiteId = $customer->getWebsiteId();
902-
if ($websiteId && !$this->isCustomerInStore($websiteId, $customer->getStoreId())) {
903-
throw new LocalizedException(__('The store view is not in the associated website.'));
904-
}
905-
906902
$storeName = $this->storeManager->getStore($customer->getStoreId())->getName();
907903
$customer->setCreatedIn($storeName);
908904
}
@@ -1144,6 +1140,22 @@ public function isCustomerInStore($customerWebsiteId, $storeId)
11441140
return in_array($storeId, $ids);
11451141
}
11461142

1143+
/**
1144+
* Validate customer store id by customer website id.
1145+
*
1146+
* @param CustomerInterface $customer
1147+
* @return bool
1148+
* @throws LocalizedException
1149+
*/
1150+
public function validateCustomerStoreIdByWebsiteId(CustomerInterface $customer)
1151+
{
1152+
if (!$this->isCustomerInStore($customer->getWebsiteId(), $customer->getStoreId())) {
1153+
throw new LocalizedException(__('The store view is not in the associated website.'));
1154+
}
1155+
1156+
return true;
1157+
}
1158+
11471159
/**
11481160
* Validate the Reset Password Token for a customer.
11491161
*

app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/SaveTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ protected function setUp()
269269
->getMock();
270270
$this->managementMock = $this->getMockBuilder(AccountManagement::class)
271271
->disableOriginalConstructor()
272-
->setMethods(['createAccount'])
272+
->setMethods(['createAccount', 'validateCustomerStoreIdByWebsiteId'])
273273
->getMock();
274274
$this->addressDataFactoryMock = $this->getMockBuilder(AddressInterfaceFactory::class)
275275
->disableOriginalConstructor()
@@ -522,6 +522,9 @@ public function testExecuteWithExistentCustomer()
522522
->with('customer/*/edit', ['id' => $customerId, '_current' => true])
523523
->willReturn(true);
524524

525+
$this->managementMock->method('validateCustomerStoreIdByWebsiteId')
526+
->willReturn(true);
527+
525528
$this->assertEquals($redirectMock, $this->model->execute());
526529
}
527530

0 commit comments

Comments
 (0)