当前位置: 首页>>代码示例>>PHP>>正文


PHP CRM_Utils_System::authenticate方法代码示例

本文整理汇总了PHP中CRM_Utils_System::authenticate方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Utils_System::authenticate方法的具体用法?PHP CRM_Utils_System::authenticate怎么用?PHP CRM_Utils_System::authenticate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CRM_Utils_System的用法示例。


在下文中一共展示了CRM_Utils_System::authenticate方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: authenticate

 /**
  * Authentication wrapper to the UF Class
  *
  * @param string $name      Login name
  * @param string $pass      Password
  * @return string           The REST Client key
  * @access public
  * @static
  */
 public function authenticate($name, $pass)
 {
     require_once 'CRM/Utils/System.php';
     require_once 'CRM/Core/DAO.php';
     $result =& CRM_Utils_System::authenticate($name, $pass);
     if (empty($result)) {
         return self::error('Could not authenticate user, invalid name or password.');
     }
     $session = CRM_Core_Session::singleton();
     $api_key = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $result[0], 'api_key');
     if (empty($api_key)) {
         // These two lines can be used to set the initial value of the key.  A better means is needed.
         //CRM_Core_DAO::setFieldValue('CRM_Contact_DAO_Contact', $result[0], 'api_key', sha1($result[2]) );
         //$api_key = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $result[0], 'api_key');
         return self::error("This user does not have a valid API key in the database, and therefore cannot authenticate through this interface");
     }
     // Test to see if I can pull the data I need, since I know I have a good value.
     $user =& CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $api_key, 'id', $api_key);
     $session->set('api_key', $api_key);
     $session->set('key', $result[2]);
     $session->set('rest_time', time());
     $session->set('PHPSESSID', session_id());
     $session->set('cms_user_id', $result[1]);
     return self::simple(array('api_key' => $api_key, 'PHPSESSID' => session_id(), 'key' => sha1($result[2])));
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:34,代码来源:REST.php

示例2: authenticateScript

 /**
  * @param bool $abort
  * @param null $name
  * @param null $pass
  * @param bool $storeInSession
  * @param bool $loadCMSBootstrap
  * @param bool $requireKey
  *
  * @return bool
  */
 public static function authenticateScript($abort = TRUE, $name = NULL, $pass = NULL, $storeInSession = TRUE, $loadCMSBootstrap = TRUE, $requireKey = TRUE)
 {
     // auth to make sure the user has a login/password to do a shell operation
     // later on we'll link this to acl's
     if (!$name) {
         $name = trim(CRM_Utils_Array::value('name', $_REQUEST));
         $pass = trim(CRM_Utils_Array::value('pass', $_REQUEST));
     }
     // 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", $abort);
     }
     if ($requireKey && !self::authenticateKey($abort)) {
         return FALSE;
     }
     $result = CRM_Utils_System::authenticate($name, $pass, $loadCMSBootstrap);
     if (!$result) {
         return self::authenticateAbort("ERROR: Invalid username and/or password\n", $abort);
     } elseif ($storeInSession) {
         // 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", $abort);
         }
     }
     return $result;
 }
开发者ID:rollox,项目名称:civicrm-core,代码行数:40,代码来源:System.php

示例3: authenticateScript

 static function authenticateScript($abort = true, $name = null, $pass = null, $storeInSession = true)
 {
     // auth to make sure the user has a login/password to do a shell
     // operation
     // later on we'll link this to acl's
     if (!$name) {
         $name = trim(CRM_Utils_Array::value('name', $_REQUEST));
         $pass = trim(CRM_Utils_Array::value('pass', $_REQUEST));
     }
     if (!$name) {
         // its ok to have an empty password
         return self::authenticateAbort("ERROR: You need to send a valid user name and password to execute this file\n", $abort);
     }
     if (!self::authenticateKey($abort)) {
         return false;
     }
     $result = CRM_Utils_System::authenticate($name, $pass);
     if (!$result) {
         return self::authenticateAbort("ERROR: Invalid username and/or password\n", $abort);
     } else {
         if ($storeInSession) {
             // lets store contact id and user id in session
             list($userID, $ufID, $randomNumber) = $result;
             if ($userID && $ufID) {
                 $session = CRM_Core_Session::singleton();
                 $session->set('ufID', $ufID);
                 $session->set('userID', $userID);
             } else {
                 return self::authenticateAbort("ERROR: Unexpected error, could not match userID and contactID", $abort);
             }
         }
     }
     return $result;
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:34,代码来源:System.php

示例4: authenticate

 /**
  * Authentication wrapper to the UF Class.
  *
  * @param string $name
  *   Login name.
  * @param string $pass
  *   Password.
  *
  * @param bool $loadCMSBootstrap
  *
  * @throws SoapFault
  * @return string
  *   The SOAP Client key
  */
 public function authenticate($name, $pass, $loadCMSBootstrap = FALSE)
 {
     require_once str_replace('_', DIRECTORY_SEPARATOR, $this->ufClass) . '.php';
     if ($this->ufClass == 'CRM_Utils_System_Joomla' || $this->ufClass == 'CRM_Utils_System_WordPress') {
         $loadCMSBootstrap = TRUE;
     }
     $result = CRM_Utils_System::authenticate($name, $pass, $loadCMSBootstrap);
     if (empty($result)) {
         throw new SoapFault('Client', 'Invalid login');
     }
     $session = CRM_Core_Session::singleton();
     $session->set('soap_key', $result[2]);
     $session->set('soap_time', time());
     return sha1($result[2]);
 }
开发者ID:nielosz,项目名称:civicrm-core,代码行数:29,代码来源:SoapServer.php


注:本文中的CRM_Utils_System::authenticate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。