/** * Make sure customer is logged in and put it into registry */ public function preDispatch() { parent::preDispatch(); if (!$this->getRequest()->isDispatched()) { return; } $this->_session = Mage::getSingleton('customer/session'); if (!$this->_session->authenticate($this)) { $this->setFlag('', 'no-dispatch', true); } Mage::register('current_customer', $this->_session->getCustomer()); }
/** * Limit access to protected actions. */ public function preDispatch() { parent::preDispatch(); if (!$this->getRequest()->isDispatched()) { return; } $action = $this->getRequest()->getActionName(); $openActions = array('applyPlan'); $pattern = '/^(' . implode('|', $openActions) . ')/i'; $this->_session = Mage::getSingleton('customer/session'); if (!preg_match($pattern, $action)) { if (!$this->_session->authenticate($this)) { $this->setFlag('', 'no-dispatch', true); } Mage::register('current_customer', $this->_session->getCustomer()); } else { $this->_session->setNoReferer(true); } }
/** * the single login session should always have an active * user, the user should match the configuration rules. * * @param Mage_Customer_Model_Session $customerSession * @return boolean */ public function validateAnonymousLoginSession($customerSession) { /** * @var $config Vbw_Punchout_Helper_Config * @var $session Vbw_Punchout_Model_Session */ $config = Mage::helper('vbw_punchout/config'); $groupId = $config->getAnonymousLoginGroup(); if (!empty($groupId)) { if ($customerSession->getCustomerGroupId() != 0) { $customer = $customerSession->getCustomer(); $customer->setGroupId($customerSession->getCustomerGroupId()); $quote = Mage::getSingleton('checkout/session')->getQuote(); $quote->setCustomer($customer); // $customerSession->setCustomerAsLoggedIn($customer); } } }