Merge pull request #2387 from pratik-joshi/CRM-13973
[civicrm-core.git] / CRM / Core / Config.php
index 459faf837031547f1e5dc59efd429cbdd4680a6d..ee12caba087bb1a71aecc402b900ac427e319478 100644 (file)
@@ -167,7 +167,7 @@ class CRM_Core_Config extends CRM_Core_Config_Variables {
    * @param $loadFromDB boolean  whether to load from the database
    * @param $force      boolean  whether to force a reconstruction
    *
-   * @return object
+   * @return CRM_Core_Config
    * @static
    */
   static function &singleton($loadFromDB = TRUE, $force = FALSE) {
@@ -242,6 +242,9 @@ class CRM_Core_Config extends CRM_Core_Config_Variables {
           array(1 => array($userID, 'Integer'))
         );
       }
+
+      // initialize authentication source
+      self::$_singleton->initAuthSrc();
     }
     return self::$_singleton;
   }
@@ -652,6 +655,17 @@ class CRM_Core_Config extends CRM_Core_Config_Variables {
     CRM_Core_DAO::executeQuery($query);
   }
 
+  // This method should initialize auth sources
+  function initAuthSrc() {
+    $session = CRM_Core_Session::singleton();
+    if ($session->get('userID') && !$session->get('authSrc')) {
+      $session->set('authSrc', CRM_Core_Permission::AUTH_SRC_LOGIN);
+    }
+
+    // checksum source
+    CRM_Contact_BAO_Contact_Permission::initChecksumAuthSrc();
+  }
+
   /**
    * one function to get domain ID
    */