This is my LoginForm model:
<?
class LoginForm extends CFormModel
{
public $username;
public $password;
private $_identity;
function rules()
{
return array(
array("username, password","required"),
array('password', 'authenticate'),
);
}
public function authenticate($attribute,$params)
{
$this->_identity=new UserIdentity($this->username,$this->password);
if(!$this->_identity->authenticate())
$this->addError('password','Incorrect username or password.');
}
}
?>
In controller:
$model = new User;
$model->attributes = $_POST["User"];
if ($model->validate())
.........................
I tested with some incorrect username and password but validate() function always return "true"
Why ?