Skip to content

Commit 98637e4

Browse files
author
Mohan Ahuja
committed
ACP2E-98: Customer with global account sharing has to login again in the secondary website when guest checkout is disabled
- Added new JS file to refresh the user local storage data if the user session is set but the local data is not yet set
1 parent 2d44647 commit 98637e4

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

app/code/Magento/Customer/view/frontend/requirejs-config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ var config = {
1414
addressValidation: 'Magento_Customer/js/addressValidation',
1515
showPassword: 'Magento_Customer/js/show-password',
1616
'Magento_Customer/address': 'Magento_Customer/js/address',
17-
'Magento_Customer/change-email-password': 'Magento_Customer/js/change-email-password'
17+
'Magento_Customer/change-email-password': 'Magento_Customer/js/change-email-password',
18+
globalSessionLoader: 'Magento_Customer/js/customer-global-session-loader.js'
1819
}
1920
}
2021
};

app/code/Magento/Customer/view/frontend/templates/account/authentication-popup.phtml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
"*": {
2020
"Magento_Ui/js/block-loader": "<?= $block->escapeJs($block->escapeUrl($block->getViewFileUrl(
2121
'images/loader-1.gif'
22-
))) ?>"
22+
))) ?>",
23+
"Magento_Customer/js/customer-global-session-loader": {}
2324
}
2425
}
2526
</script>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/**
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
define([
7+
'jquery',
8+
'Magento_Customer/js/customer-data'
9+
], function ($, customerData) {
10+
'use strict';
11+
12+
return function () {
13+
var customer = customerData.get('customer');
14+
15+
// When the session is available, this customer menu will be available
16+
if ($('.customer-menu').length > 0) {
17+
customerData.getInitCustomerData().done(function () {
18+
// Check if the customer data is set in local storage, if not reload data from server
19+
if (!customer().firstname) {
20+
customerData.reload([], false);
21+
}
22+
});
23+
}
24+
};
25+
});

0 commit comments

Comments
 (0)