Quantcast
Channel: Yii Framework Forum
Viewing all articles
Browse latest Browse all 18717

Blog Tutorial

$
0
0
Hi All,

I am following the blog tutorial. Instead of using a table called tbl_user, I am using a table called tbl_rider.

I have used the gii tool to make a model called Rider in Rider.php in the models folder. I have generated the CRUD functions and used the create form view to create one row in the table with the important columns email and password populated. I queried the table and row is there with an unecrypted password.

I assumed all I would need to do was replace all of the instances of User with Rider and the username with password and it would function correctly.

My code follows:
class UserIdentity extends CUserIdentity
{

        private $_id;
        
	public function authenticate()
	{
                $email=strtolower($this->email);
                $rider=Rider::model()->find('LOWER(email)=?',array($email));
                if($rider===null)
                    $this->errorCode=self::ERROR_USERNAME_INVALID;
                else if(!$rider->validatePassword($this->password))
                    $this->errorCode=self::ERROR_PASSWORD_INVALID;
                else
                {
                    $this->_id=$rider->id;
                    $this->email=$rider->username;
                    $this->errorCode=self::ERROR_NONE;
                }
                return $this->errorCode==self::ERROR_NONE;
        }
        public function getId()
        {
            return $this->_id;
        }
}


My table tbl_rider has the columns: rider_id, email, password.

I get an exception - Property "UserIdentity.email" is not defined. This line is highlighted - $email=strtolower($this->email);

What's the problem with my code?

Viewing all articles
Browse latest Browse all 18717

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>