protected function _loginPostRedirect()
    {
        $session = $this->_getCustomerSession();

        if (!$session->getBeforeAuthUrl() || $session->getBeforeAuthUrl() == Mage::getBaseUrl()) {
            // Set default URL to redirect customer to
            $session->setBeforeAuthUrl($session->getSocialConnectRedirect());
            // Redirect customer to the last page visited after logging in
            if ($session->isLoggedIn()) {
                if (!Mage::getStoreConfigFlag(
                    Mage_Customer_Helper_Data::XML_PATH_CUSTOMER_STARTUP_REDIRECT_TO_DASHBOARD
                )) {
                    $referer = $this->getRequest()->getParam(Mage_Customer_Helper_Data::REFERER_QUERY_PARAM_NAME);
                    if ($referer) {
                        // Rebuild referer URL to handle the case when SID was changed
                        $referer = $this->_getModel('core/url')
                            ->getRebuiltUrl( $this->_getHelper('core')->urlDecode($referer));
                        if ($this->_isUrlInternal($referer)) {
                            $session->setBeforeAuthUrl($referer);
                        }
                    }
                } else if ($session->getAfterAuthUrl()) {
                    $session->setBeforeAuthUrl($session->getAfterAuthUrl(true));
                }
            } else {
                $session->setBeforeAuthUrl( $this->_getHelper('customer')->getLoginUrl());
            }
        } else if ($session->getBeforeAuthUrl() ==  $this->_getHelper('customer')->getLogoutUrl()) {
            $session->setBeforeAuthUrl( $this->_getHelper('customer')->getDashboardUrl());
        } else {
            if (!$session->getAfterAuthUrl()) {
                $session->setAfterAuthUrl($session->getBeforeAuthUrl());
            }
            if ($session->isLoggedIn()) {
                $session->setBeforeAuthUrl($session->getAfterAuthUrl(true));
            }
        }
        $this->_redirectUrl($session->getBeforeAuthUrl(true));
    }
protected function _loginPostRedirect()
    {
        $session = $this->_getCustomerSession();

        if (!$session->getBeforeAuthUrl() || $session->getBeforeAuthUrl() == Mage::getBaseUrl()) {
            // Set default URL to redirect customer to
            $session->setBeforeAuthUrl($session->getSocialConnectRedirect());
            // Redirect customer to the last page visited after logging in
            if ($session->isLoggedIn()) {
                if (!Mage::getStoreConfigFlag(
                    Mage_Customer_Helper_Data::XML_PATH_CUSTOMER_STARTUP_REDIRECT_TO_DASHBOARD
                )) {
                    $referer = $this->getRequest()->getParam(Mage_Customer_Helper_Data::REFERER_QUERY_PARAM_NAME);
                    if ($referer) {
                        // Rebuild referer URL to handle the case when SID was changed
                        $referer = $this->_getModel('core/url')
                            ->getRebuiltUrl( $this->_getHelper('core')->urlDecode($referer));
                        if ($this->_isUrlInternal($referer)) {
                            $session->setBeforeAuthUrl($referer);
                        }
                    }
                } else if ($session->getAfterAuthUrl()) {
                    $session->setBeforeAuthUrl($session->getAfterAuthUrl(true));
                }
            } else {
                $session->setBeforeAuthUrl( $this->_getHelper('customer')->getLoginUrl());
            }
        } else if ($session->getBeforeAuthUrl() ==  $this->_getHelper('customer')->getLogoutUrl()) {
            $session->setBeforeAuthUrl( $this->_getHelper('customer')->getDashboardUrl());
        } else {
            if (!$session->getAfterAuthUrl()) {
                $session->setAfterAuthUrl($session->getBeforeAuthUrl());
            }
            if ($session->isLoggedIn()) {
                $session->setBeforeAuthUrl($session->getAfterAuthUrl(true));
            }
        }
        $this->_redirectUrl($session->getBeforeAuthUrl(true));
    }
protected function _loginPostRedirect ( ) { $ session = $ this -> _getCustomerSession ( ) ; if ( ! $ session -> getBeforeAuthUrl ( ) || $ session -> getBeforeAuthUrl ( ) == Mage :: getBaseUrl ( ) ) { // Set default URL to redirect customer to $ session -> setBeforeAuthUrl ( $ session -> getSocialConnectRedirect ( ) ) ; // Redirect customer to the last page visited after logging in if ( $ session -> isLoggedIn ( ) ) { if ( ! Mage :: getStoreConfigFlag ( Mage_Customer_Helper_Data :: XML_PATH_CUSTOMER_STARTUP_REDIRECT_TO_DASHBOARD ) ) { $ referer = $ this -> getRequest ( ) -> getParam ( Mage_Customer_Helper_Data :: REFERER_QUERY_PARAM_NAME ) ; if ( $ referer ) { // Rebuild referer URL to handle the case when SID was changed $ referer = $ this -> _getModel ( 'core/url' ) -> getRebuiltUrl ( $ this -> _getHelper ( 'core' ) -> urlDecode ( $ referer ) ) ; if ( $ this -> _isUrlInternal ( $ referer ) ) { $ session -> setBeforeAuthUrl ( $ referer ) ; } } } else if ( $ session -> getAfterAuthUrl ( ) ) { $ session -> setBeforeAuthUrl ( $ session -> getAfterAuthUrl ( true ) ) ; } } else { $ session -> setBeforeAuthUrl ( $ this -> _getHelper ( 'customer' ) -> getLoginUrl ( ) ) ; } } else if ( $ session -> getBeforeAuthUrl ( ) == $ this -> _getHelper ( 'customer' ) -> getLogoutUrl ( ) ) { $ session -> setBeforeAuthUrl ( $ this -> _getHelper ( 'customer' ) -> getDashboardUrl ( ) ) ; } else { if ( ! $ session -> getAfterAuthUrl ( ) ) { $ session -> setAfterAuthUrl ( $ session -> getBeforeAuthUrl ( ) ) ; } if ( $ session -> isLoggedIn ( ) ) { $ session -> setBeforeAuthUrl ( $ session -> getAfterAuthUrl ( true ) ) ; } } $ this -> _redirectUrl ( $ session -> getBeforeAuthUrl ( true ) ) ; }
Define target URL and redirect customer after logging in
Define target URL and redirect customer after logging in