Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed customer data sometimes not being cleared when logging in as customer #16

Merged
merged 3 commits into from
Apr 3, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion etc/webrestrictions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,5 @@
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_WebsiteRestriction:etc/webrestrictions.xsd">
<action path="loginascustomer_login_index" type="generic" />
<action path="loginascustomer_login_post" type="generic" />
<action path="loginascustomer_login_proceed" type="generic" />
</config>
23 changes: 10 additions & 13 deletions view/frontend/templates/login.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,15 @@
*
* Glory to Ukraine! Glory to the heroes!
*/
/** @var \Magento\Framework\View\Element\Template $block */
Copy link
Contributor

@nntoan nntoan Mar 29, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@erfanimani Can you please use the equivalent block class name instead? Otherwise, it looks really good 👍

?>
<p><?php /* @escapeNotVerified */ echo __('You have logged in and will go to customer account in 5 seconds.') ?></p>
<form id="loginascustomer" method="post" action="<?php echo $block->getUrl('*/*/post') ?>">
<button style="display: none;" id="loginascustomer-button" type="submit" class="action save primary" title=""><span> >> </span></button>
</form>
<script>
require([
"jquery",
"domReady!"
], function($){
setTimeout(function(){
$('#loginascustomer-button').click();
}, 5000);
});

<script type="text/x-magento-init">
{
"*": {
"Magefan_LoginAsCustomer/js/login": {
"redirectUrl": "<?php echo $block->getUrl('customer/account/index') ?>"
}
}
}
</script>
12 changes: 12 additions & 0 deletions view/frontend/web/js/login.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
define([
'Magento_Customer/js/customer-data'
], function (customerData) {

'use strict';

return function (config) {
customerData.reload('customer').done(function () {
window.location.href = config.redirectUrl;
});
};
});