本文整理汇总了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;
}
}
示例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);
}
}