Hi All,
I am using the below code to login to application with user in database table.
even after inserting correct password it is showing incorrect login or password.
my login form and login module is having default configuration, i have not done any changes in this files.
can anyone please suggest where i am going wrong.
My model name is customer
class UserIdentity extends CUserIdentity
{
private $_id;
public function authenticate()
{
$user=Customer::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->errorCode=self::ERROR_NONE;
return !$this->errorCode;
}
public function getId()
{
return $this->_id;
}
}
model customer.php
protected function afterValidate()
{
parent::afterValidate();
$this->password = $this->encrypt($this->password);
}
public function encrypt($value)
{
return md5($value);
}
public function attributeLabels()
{
return array(
'name' => 'Name',
'tst_id' => 'Tst',
'username' => 'Username',
'password' => 'Password',
'email' => 'Email',
Thanks in advance