Vinai / customer-activation

Magento extension which makes it impossible for a customer to log in until the account has been activated by the administrator.
120 stars 59 forks source link

Customer logged in at registration when persistent cart is enabled #113

Open joolswills opened 7 years ago

joolswills commented 7 years ago

If the Magento persistent cart is enabled, when registering a customer is automatically logged in.

To fix it I am currently testing these changes:

Index: app/code/community/Netzarbeiter/CustomerActivation/Model/Observer.php
===================================================================
--- app/code/community/Netzarbeiter/CustomerActivation/Model/Observer.php   (revision 4002)
+++ app/code/community/Netzarbeiter/CustomerActivation/Model/Observer.php   (working copy)
@@ -50,6 +50,9 @@
                 ->setId(null)
                 ->setCustomerGroupId(Mage_Customer_Model_Group::NOT_LOGGED_IN_ID);

+            Mage::getModel('persistent/session')->removePersistentCookie();
+            Mage::helper('persistent/session')->setSession(null);
+
             if ($this->_checkRequestRoute('customer', 'account', 'createpost')) {
                 /*
                  * If this is a regular registration, simply display message

Once they have been tested in production, I will create a PR. But this may be useful for others in the meantime.

joolswills commented 7 years ago

this may not work if persistent cart is not being used too, so I need to check that.