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 all commits
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 Block/Adminhtml/Customer/Edit/Login.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,4 @@ public function getInvalidateTokenUrl()
{
return $this->getUrl('loginascustomer/login/login', ['customer_id' => $this->getCustomerId()]);
}

}
1 change: 0 additions & 1 deletion Block/Adminhtml/System/Config/Form/Info.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,4 @@ public function render(\Magento\Framework\Data\Form\Element\AbstractElement $ele

return $html;
}

}
1 change: 0 additions & 1 deletion Controller/Login/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,4 @@ protected function _initLogin()
return false;
}
}

}
25 changes: 0 additions & 25 deletions Controller/Login/Post.php

This file was deleted.

1 change: 0 additions & 1 deletion Controller/Login/Proceed.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,4 @@ public function execute()
$this->_view->loadLayout();
$this->_view->renderLayout();
}

}
1 change: 0 additions & 1 deletion Model/AdminNotificationFeed.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,5 +166,4 @@ public function setLastUpdate()
$this->_cacheManager->save(time(), 'magefan_admin_notifications_lastcheck');
return $this;
}

}
1 change: 0 additions & 1 deletion Model/Login.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,5 +220,4 @@ public function generate($adminId)
'created_at' => $this->_dateTime->gmtTimestamp(),
])->save();
}

}
1 change: 0 additions & 1 deletion Model/ResourceModel/Login.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,4 @@ protected function _construct()
{
$this->_init('magefan_login_as_customer', 'login_id');
}

}
1 change: 0 additions & 1 deletion Model/ResourceModel/Login/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,4 @@ protected function _construct()
parent::_construct();
$this->_init('Magefan\LoginAsCustomer\Model\Login', 'Magefan\LoginAsCustomer\Model\ResourceModel\Login');
}

}
1 change: 0 additions & 1 deletion Model/ResourceModel/Login/Grid/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,4 @@ protected function _initSelect()
);
return $this;
}

}
1 change: 0 additions & 1 deletion Ui/Component/Listing/Column/Actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,4 @@ public function prepareDataSource(array $dataSource)

return $dataSource;
}

}
2 changes: 1 addition & 1 deletion etc/adminhtml/routes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
<module name="Magefan_LoginAsCustomer" />
</route>
</router>
</config>
</config>
2 changes: 1 addition & 1 deletion etc/frontend/events.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
<event name="websiterestriction_frontend">
<observer name="magefan_las_websiterestriction_frontend" instance="Magefan\LoginAsCustomer\Observer\WbsiterestrictionFrontendObserver" />
</event>
</config>
</config>
2 changes: 1 addition & 1 deletion etc/frontend/routes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
<module name="Magefan_LoginAsCustomer" />
</route>
</router>
</config>
</config>
13 changes: 0 additions & 13 deletions etc/frontend/sections.xml

This file was deleted.

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>
2 changes: 1 addition & 1 deletion view/adminhtml/ui_component/customer_listing.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@
</argument>
</actionsColumn>
</columns>
</listing>
</listing>
2 changes: 1 addition & 1 deletion view/frontend/layout/loginascustomer_login_proceed.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@
<block class="Magento\Framework\View\Element\Template" name="loginascustomer_login" template="Magefan_LoginAsCustomer::login.phtml"/>
</referenceContainer>
</body>
</page>
</page>
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;
});
};
});