$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
);
}
// 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
);
}
$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
);
}
// 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
);
}
*/
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);
}