X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FUtils%2FSystem.php;h=b85e420c3d2c519a15cfcbd428568c14d95ddea3;hb=d0f466d1aec3f5f2f9f24635470a7df8d15b9b11;hp=7ca056c27fade8efbbf98d5fedba51f9c7323339;hpb=6405aa4da337dae1792aae9ab08f9fa5e05081bf;p=civicrm-core.git diff --git a/CRM/Utils/System.php b/CRM/Utils/System.php index 7ca056c27f..b85e420c3d 100644 --- a/CRM/Utils/System.php +++ b/CRM/Utils/System.php @@ -494,29 +494,31 @@ class CRM_Utils_System { $docAdd = "More info at:" . CRM_Utils_System::docURL2("Managing Scheduled Jobs", TRUE, NULL, NULL, NULL, "wiki"); if (!$key) { - return self::authenticateAbort("ERROR: You need to send a valid key to execute this file. " . $docAdd . "\n", + return self::authenticateAbort( + "ERROR: You need to send a valid key to execute this file. " . $docAdd . "\n", $abort ); } $siteKey = defined('CIVICRM_SITE_KEY') ? CIVICRM_SITE_KEY : NULL; - if (!$siteKey || - empty($siteKey) - ) { - return self::authenticateAbort("ERROR: You need to set a valid site key in civicrm.settings.php. " . $docAdd . "\n", + if (!$siteKey || empty($siteKey)) { + return self::authenticateAbort( + "ERROR: You need to set a valid site key in civicrm.settings.php. " . $docAdd . "\n", $abort ); } if (strlen($siteKey) < 8) { - return self::authenticateAbort("ERROR: Site key needs to be greater than 7 characters in civicrm.settings.php. " . $docAdd . "\n", + return self::authenticateAbort( + "ERROR: Site key needs to be greater than 7 characters in civicrm.settings.php. " . $docAdd . "\n", $abort ); } if ($key !== $siteKey) { - return self::authenticateAbort("ERROR: Invalid key value sent. " . $docAdd . "\n", + return self::authenticateAbort( + "ERROR: Invalid key value sent. " . $docAdd . "\n", $abort ); } @@ -535,7 +537,8 @@ class CRM_Utils_System { // its ok to have an empty password if (!$name) { - return self::authenticateAbort("ERROR: You need to send a valid user name and password to execute this file\n", + return self::authenticateAbort( + "ERROR: You need to send a valid user name and password to execute this file\n", $abort ); } @@ -546,7 +549,8 @@ class CRM_Utils_System { $result = CRM_Utils_System::authenticate($name, $pass, $loadCMSBootstrap); if (!$result) { - return self::authenticateAbort("ERROR: Invalid username and/or password\n", + return self::authenticateAbort( + "ERROR: Invalid username and/or password\n", $abort ); } @@ -554,12 +558,12 @@ class CRM_Utils_System { // lets store contact id and user id in session list($userID, $ufID, $randomNumber) = $result; if ($userID && $ufID) { - $config = CRM_Core_Config::singleton(); $config->userSystem->setUserSession( array($userID, $ufID) ); } else { - return self::authenticateAbort("ERROR: Unexpected error, could not match userID and contactID", + return self::authenticateAbort( + "ERROR: Unexpected error, could not match userID and contactID", $abort ); } @@ -582,6 +586,16 @@ class CRM_Utils_System { */ static function authenticate($name, $password, $loadCMSBootstrap = FALSE, $realPath = NULL) { $config = CRM_Core_Config::singleton(); + + // before we do any loading, lets start the session and write to it + // we typically call authenticate only when we need to bootstrap the CMS directly via Civi + // and hence bypass the normal CMS auth and bootstrap process + // typically done in cli and cron scripts + // CRM-12648 + $session = CRM_Core_Session::singleton(); + $session->set( 'civicrmInitSession', TRUE ); + + $dbDrupal = DB::connect($config->userFrameworkDSN); return $config->userSystem->authenticate($name, $password, $loadCMSBootstrap, $realPath); }