當前位置: 首頁>>代碼示例>>PHP>>正文


PHP UserIdentity::encrypt_decrypt方法代碼示例

本文整理匯總了PHP中UserIdentity::encrypt_decrypt方法的典型用法代碼示例。如果您正苦於以下問題:PHP UserIdentity::encrypt_decrypt方法的具體用法?PHP UserIdentity::encrypt_decrypt怎麽用?PHP UserIdentity::encrypt_decrypt使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在UserIdentity的用法示例。


在下文中一共展示了UserIdentity::encrypt_decrypt方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: login

 /**
  * Logs in the user using the given username and password in the model.
  * @return boolean whether login is successful
  */
 public function login()
 {
     if ($this->_identity === null) {
         $this->_identity = new UserIdentity($this->username, $this->password);
         $this->_identity->authenticate();
     }
     if ($this->_identity->errorCode === UserIdentity::ERROR_NONE) {
         $duration = $this->rememberMe ? 3600 * 24 * 30 : 0;
         // 30 days
         Yii::app()->user->login($this->_identity, $duration);
         //SESSION HERE
         Yii::app()->session->add('username', UserIdentity::encrypt_decrypt('encrypt', $this->username));
         Yii::app()->session->add('password', UserIdentity::encrypt_decrypt('encrypt', $this->password));
         return true;
     } else {
         return false;
     }
 }
開發者ID:emircado,項目名稱:pamgmt,代碼行數:22,代碼來源:LoginForm.php

示例2: __construct

 public function __construct($username = null, $password = null)
 {
     // bind and connect to the server
     if ($username == null || $password == null) {
         if (isset($_SESSION['username']) && isset($_SESSION['password'])) {
             $username = UserIdentity::encrypt_decrypt('decrypt', Yii::app()->session['username']);
             $password = UserIdentity::encrypt_decrypt('decrypt', Yii::app()->session['password']);
         } else {
             throw new LDAPQueryException('Username and/or password missing');
         }
     }
     $options = Yii::app()->params['ldap'];
     $this->connection = ldap_connect($options['host']);
     ldap_set_option($this->connection, LDAP_OPT_PROTOCOL_VERSION, 3);
     ldap_set_option($this->connection, LDAP_OPT_REFERRALS, 0);
     ldap_start_tls($this->connection);
     if ($this->connection) {
         // Note: in general it is bad to hide errors, however we're checking for an error below
         $this->bind = @ldap_bind($this->connection, "uid={$username},ou={$options['ou']},{$options['base_dn']}", $password);
     }
 }
開發者ID:emircado,項目名稱:pamgmt,代碼行數:21,代碼來源:LDAPQuery.php


注:本文中的UserIdentity::encrypt_decrypt方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。