Magento Module: Login Director

A multi-store login detection system which would prompt visitors with cross-website accounts to select their destination store view.

Details

This module was developed to allow visitors to sign into any store view and, upon detection of matching account by e-mail address across multiple websites in the application, be prompted to select the desired store view.

The purpose for this module was to reduce account access friction and confusion, since the application served a B2C and B2B audience with cross-over between customers.

The module had to be developed for compatibility with an existing store login control extension.

Screenshots

Step 1: Sign-in from top navigation pop-out

Step 2: Receive prompt to select destination store

Technical Features

Code Sample

public function processCustomerLogin(Varien_Event_Observer $observer)
{
    try {
        if (!$this->_isEnabled()) {
            return;
        }

        if ($this->_getSession()->getDisableLoginDirectorFlag()) {
            return;
        }

        $this->_getSession()->unsAllowedStoreIds();

        $customer   = $observer->getEvent()->getCustomer();
        $data       = Mage::getModel('itoris_stlc/customer')->loadCustomer($customer, true);

        $this->_filterStoreAccessData($data, $customer);

        if (count($data) > 1) {
            $this->_getSession()->setAllowedStoreIds(array_keys($data));

            if ($this->_isInlineMode()) {
                $this->_getSession()->renewSession();

                $this->_sendInlineResponse($this->_getLoginDirectorUrl(true));
            } else {
                $this->_getSession()->setAfterAuthUrl($this->_getLoginDirectorUrl());
            }
        } else if ($this->_isInlineMode()) {
            $this->_sendInlineResponse(Mage::helper('customer')->getDashboardUrl(), true);
        }
    } catch (Exception $error) {
        Mage::logException($error);
    }
}

Static Analysis