CUserIdentity

CDbHttpSession

Yii Framework v1.1.10 类参考

CUserIdentity

system.web.auth
继承 class CUserIdentity » CBaseUserIdentity » CComponent
实现 IUserIdentity
源自 1.0
版本 $Id: CUserIdentity.php 3426 2011-10-25 00:01:09Z alexander.makarow $
源码 framework/web/auth/CUserIdentity.php
CUserIdentity是一个基于用户名验证的身份和密码的基类

派生类应该使用实际的验证机制来实现authenticate, (比如说,对照数据表来检查用户名和密码)。

默认是,CUserIdentity认为username是唯一的识别, 因为把它当作ID来检查。

公共属性

隐藏继承属性

属性类型描述定义在
errorCode integer 验证错误代码。如果是有错误发生,那么错误代码不会为0。 默认是100,意味着未知的身份。调用authenticate可以改变这个值。 CBaseUserIdentity
errorMessage string 验证错误信息。默认为空。 CBaseUserIdentity
id string 返回唯一的身份标识。 CUserIdentity
isAuthenticated 验证是否成功。 返回值说明身份是否通过验证。 CBaseUserIdentity
name string 返回身份的显示名字。 CUserIdentity
password string 密码 CUserIdentity
persistentStates array 返回需要持久化的身份状态。 CBaseUserIdentity
username string 用户名 CUserIdentity

公共方法

隐藏继承方法

方法描述定义在
__call() 如果类中没有调的方法名,则调用这个方法。 CComponent
__construct() 构造方法 CUserIdentity
__get() 返回一个属性值、一个事件处理程序列表或一个行为名称。 CComponent
__isset() 检查一个属性是否为null。 CComponent
__set() 设置一个组件的属性值。 CComponent
__unset() 设置一个组件的属性为null。 CComponent
asa() 返回这个名字的行为对象。 CComponent
attachBehavior() 附加一个行为到组件。 CComponent
attachBehaviors() 附加一个行为列表到组件。 CComponent
attachEventHandler() 为事件附加一个事件处理程序。 CComponent
authenticate() 基于usernamepassword对用户进行验证。 CUserIdentity
canGetProperty() 确定属性是否可读。 CComponent
canSetProperty() 确定属性是否可写。 CComponent
clearState() 移除指定的状态。 CBaseUserIdentity
detachBehavior() 从组件中分离一个行为。 CComponent
detachBehaviors() 从组件中分离所有行为。 CComponent
detachEventHandler() 分离一个存在的事件处理程序。 CComponent
disableBehavior() 禁用一个附加行为。 CComponent
disableBehaviors() 禁用组件附加的所有行为。 CComponent
enableBehavior() 启用一个附加行为。 CComponent
enableBehaviors() 启用组件附加的所有行为。 CComponent
evaluateExpression() 计算一个PHP表达式,或根据组件上下文执行回调。 CComponent
getEventHandlers() 返回一个事件的附加处理程序列表。 CComponent
getId() 返回唯一的身份标识。 CUserIdentity
getIsAuthenticated() 返回值说明身份是否通过验证。 CBaseUserIdentity
getName() 返回身份的显示名字。 CUserIdentity
getPersistentStates() 返回需要持久化的身份状态。 CBaseUserIdentity
getState() 获取指定名字的持久化状态。 CBaseUserIdentity
hasEvent() 确定一个事件是否定义。 CComponent
hasEventHandler() 检查事件是否有附加的处理程序。 CComponent
hasProperty() 确定属性是否被定义。 CComponent
raiseEvent() 发起一个事件。 CComponent
setPersistentStates() 设置持久化状态数组。 CBaseUserIdentity
setState() 设置指定状态的值。 CBaseUserIdentity

属性详细

id 属性 只读
public string getId()

返回唯一的身份标识。 默认实现会返回username。 此方法为接口IUserIdentity强制要求实现。

name 属性 只读
public string getName()

返回身份的显示名字。 默认实现返回username。 此方法为接口IUserIdentity强制要求实现。

password 属性
public string $password;

密码

username 属性
public string $username;

用户名

方法详细

__construct() 方法
public void __construct(string $username, string $password)
$username string 用户名
$password string 密码
源码: framework/web/auth/CUserIdentity.php#44 (显示)
public function __construct($username,$password)
{
    
$this->username=$username;
    
$this->password=$password;
}

构造方法

authenticate() 方法
public boolean authenticate()
{return} boolean 是否验证成功。
源码: framework/web/auth/CUserIdentity.php#56 (显示)
public function authenticate()
{
    throw new 
CException(Yii::t('yii','{class}::authenticate() must be implemented.',array('{class}'=>get_class($this))));
}

基于usernamepassword对用户进行验证。 派生类应该重写这个方法,否则就会抛出异常。 此方法为接口IUserIdentity强制要求实现。

getId() 方法
public string getId()
{return} string the unique identifier for the identity.
源码: framework/web/auth/CUserIdentity.php#67 (显示)
public function getId()
{
    return 
$this->username;
}

返回唯一的身份标识。 默认实现会返回username。 此方法为接口IUserIdentity强制要求实现。

getName() 方法
public string getName()
{return} string 标识的显示名字。
源码: framework/web/auth/CUserIdentity.php#78 (显示)
public function getName()
{
    return 
$this->username;
}

返回身份的显示名字。 默认实现返回username。 此方法为接口IUserIdentity强制要求实现。

Copyright © 2008-2011 by Yii Software LLC
All Rights Reserved.