Blog tutorial problem: UserIdentity class

I was following the blog tutorial on the yii tutorial site.

In "Authenticating User" section, I cannot login using UserIdentity code

posted in the tutorial. I get a blank screen.

I’m probably getting a fatal error somewhere but I don’t see the error in the apache log file.

When I step the code using the xdebug debugger, the $user object does not seemed to be constructed correctly. I can not step past the line:

if($user===null)

When I inspect $user object, I only see the classname with no other attributes.

Below is the UserIdentity class I use (from the blog tutorial).

Does anyone know the cause?

class UserIdentity extends CUserIdentity

{

private $_id;





public function authenticate()


{


    $username=strtolower($this->username);


    $user=User::model()->find('LOWER(username)=?',array($username));


    


    if($user===null)


        $this->errorCode=self::ERROR_USERNAME_INVALID;


    else 


    if(!$user->validatePassword($this->password))


        $this->errorCode=self::ERROR_PASSWORD_INVALID;


    else


    {


        $this->_id=$user->id;


        $this->username=$user->username;


        $this->errorCode=self::ERROR_NONE;


    }


    return $this->errorCode==self::ERROR_NONE;


}





public function getId()


{


    return $this->_id;


}

}

I found where the fatal error was. It was in User class (had undefined function). UserIdentity class was just fine.

Can you be more specific regarding the fix? I’m having the same problem but don’t know what you mean by “had undefined function” in User class.

Thanks in advance for the help.

I am also having a problem cannot login as user demo get the following error.

include(CPasswordHelper.php): failed to open stream: No such file or directory

@MontyEdwards: your basePath in the main.php config file and ensure that it is set correctly. The error you are getting states that you are using CPasswordHelper:: but that the autoloader cannot finder the class file to load it.

@ajzip: What does your application.php log file say? Check that file for any exceptions that are being generated and report back what you find.