caridy 2011-05-22 14:29:16 5045次浏览 17条回复 1 0 0

如下,加红的部分,即新增加一个属于,可以保存到Session中去.可通过yii::app()->user->email获取 这个东西查了半天才查到,帖出来给大家提个醒.特别是新手哈.

public function authenticate() {
    $user = User::model()->findByAttributes(array('username' => $this->username));
    if ($user === null) {
        $this->errorCode = self::ERROR_USERNAME_INVALID;
    } else {
        if ($user->password !== $user->encrypt($this->password)) {
            $this->errorCode = self::ERROR_PASSWORD_INVALID;
        } else {
            $this->_id = $user->id;
            if (null === $user->last_login_time) {
                $lastLogin = time();
            } else {
                $lastLogin = strtotime($user->last_login_time);
            }
            $this->setState('last_login_time', $lastLogin);
            [color=Red][size=6]$this->setState('email', $user->email);[/size][/color]
            $this->errorCode = self::ERROR_NONE;
        }
    }
    return!$this->errorCode;
}
您需要登录后才可以回复。登录 | 立即注册