AlexeyUna 1 год назад
Родитель
Сommit
036bffc132

+ 7 - 0
modules/base/connect/classes/BxBaseModConnectModule.php

@@ -59,12 +59,19 @@ class BxBaseModConnectModule extends BxBaseModGeneralModule
         bx_login($oProfile->getAccountId(), $bRememberMe);
 
         if ($bRedirect) {
+            //set redirect from the session if it was added
+            $oSession = BxDolSession::getInstance();
+            $sSessionKey = $this->_oConfig->getName() . '_relocate';
+            if ($oSession->isValue($sSessionKey))
+                $sCallbackUrl = $sCallbackUrl ? $sCallbackUrl : $oSession->getValue($sSessionKey);
+
             $sCallbackUrl = $sCallbackUrl ? $sCallbackUrl : $this -> _oConfig -> sDefaultRedirectUrl;
             
             if($this->_bIsApi)
                 return [bx_api_get_block('redirect', ['uri' => bx_api_get_relative_url($sCallbackUrl)])];
 
             header('Location: ' . $sCallbackUrl);
+            exit;
         }
     }
 

+ 4 - 0
modules/boonex/cas_connect/classes/BxCASModule.php

@@ -33,6 +33,10 @@ class BxCASModule extends BxBaseModConnectModule
             $this->_oTemplate->getPage(_t('_bx_cas'), $sCode);            
         } 
 	    else {
+            // add referrer to the session to redirect after login
+            if(isset($_SERVER['HTTP_REFERER']) && mb_stripos($_SERVER['HTTP_REFERER'], BX_DOL_URL_ROOT) === 0)
+                BxDolSession::getInstance()->setValue($this->_oConfig->getName() . '_relocate', $_SERVER['HTTP_REFERER']);
+
             require_once(getParam('bx_cas_path_simplesamlphp') . '/lib/_autoload.php');
 
             $as = new \SimpleSAML\Auth\Simple('default-sp');