Skip to content

Commit 232fa6b

Browse files
author
Oleksandr Osadchyi
committed
MAGETWO-59135: [Github] Customer session is shared for different customers on two websites #4842 #6468
1 parent edd846b commit 232fa6b

File tree

5 files changed

+19
-20
lines changed

5 files changed

+19
-20
lines changed

app/code/Magento/Customer/view/frontend/templates/js/customer-data/invalidation-rules.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
'website-rule' => [
1919
'Magento_Customer/js/invalidation-rules/website-rule' => [
2020
'scopeConfig' => [
21-
'website_id' => $block->getWebsiteId(),
21+
'websiteId' => $block->getWebsiteId(),
2222
]
2323
]
2424
]

app/code/Magento/Customer/view/frontend/web/js/customer-data.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ define([
214214
this.reload(storageInvalidation.keys(), false);
215215
}
216216
}
217+
217218
if (!_.isEmpty(privateContent)) {
218219
countryData = this.get('directory-data');
219220

app/code/Magento/Customer/view/frontend/web/js/invalidation-processor.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@
33
* See COPYING.txt for license details.
44
*/
55
define([
6-
"underscore",
7-
"uiElement",
6+
'underscore',
7+
'uiElement',
88
'Magento_Customer/js/customer-data'
99
], function (_, Element, customerData) {
10-
"use strict";
11-
var invalidationRules;
10+
'use strict';
1211

1312
return Element.extend({
1413
initialize: function () {
@@ -19,17 +18,18 @@ define([
1918
/**
2019
* Process all rules in loop, each rule can invalidate some sections in customer data
2120
*
22-
* @param {Object} customerData
21+
* @param {Object} customerDataObject
2322
*/
24-
process: function (customerData) {
23+
process: function (customerDataObject) {
2524
_.each(this.invalidationRules, function (rule, ruleName) {
2625
_.each(rule, function (ruleArgs, rulePath) {
2726
require([rulePath], function (Rule) {
2827
var rule = new Rule(ruleArgs);
28+
2929
if (!_.isFunction(rule.process)) {
30-
throw new Error("Rule " + ruleName + " should implement invalidationProcessor interface");
30+
throw new Error('Rule ' + ruleName + ' should implement invalidationProcessor interface');
3131
}
32-
rule.process(customerData);
32+
rule.process(customerDataObject);
3333
});
3434
});
3535
});

app/code/Magento/Customer/view/frontend/web/js/invalidation-rules/website-rule.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ define([
1212
defaults: {
1313
scopeConfig: {}
1414
},
15-
1615
/**
1716
* Takes website id from current customer data and compare it with current website id
1817
* If customer belongs to another scope, we need to invalidate current section
@@ -22,7 +21,7 @@ define([
2221
process: function (customerData) {
2322
var customer = customerData.get('customer');
2423

25-
if (this.scopeConfig && customer() && customer().websiteId != this.scopeConfig.website_id) {
24+
if (this.scopeConfig && customer() && customer().websiteId !== this.scopeConfig.websiteId) {
2625
customerData.reload(['customer']);
2726
}
2827
}

dev/tests/js/jasmine/tests/app/code/Magento/Customer/frontend/js/invalidation-processor.test.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ define([
1717
processor = new Constr({
1818
name: 'processor'
1919
});
20+
processor.invalidationRules = {
21+
'website-rule': {
22+
'Magento_Customer/js/invalidation-rules/website-rule': {
23+
process: jasmine.createSpy()
24+
}
25+
}
26+
};
2027
done();
2128
});
2229
});
@@ -26,15 +33,7 @@ define([
2633
describe('"process" method', function () {
2734
it('record status is 1', function () {
2835
var requireTmp = require;
29-
30-
processor.invalidationRules = {
31-
'website-rule': {
32-
'Magento_Customer/js/invalidation-rules/website-rule': {
33-
process: jasmine.createSpy()
34-
}
35-
}
36-
};
37-
36+
/* eslint-disable no-global-assign */
3837
require = jasmine.createSpy();
3938
processor.process();
4039

0 commit comments

Comments
 (0)