Onman, on 15 February 2010 - 09:14 AM, said:
If you want both the username and the password highlighted when either one is wrong, try
case UserIdentity::ERROR_USERNAME_INVALID:
$this->addError('username','Incorrect login details.');
$this->addError('password','');
break;
case default:
$this->addError('username','Incorrect login details.');
$this->addError('password','');
break;
By the way in that above code you have "case default:" but that is not a valid statement (gives an error), instead I used just "default:".
Also here is my class UserIdentity:
class UserIdentity extends CUserIdentity
{
private $_id;
public function authenticate()
{
$record=User::model()->findByAttributes(array('email'=>$this->username, 'enabled'=>1));
if($record===null)
$this->errorCode=self::ERROR_USERNAME_INVALID;
else if($record->password!==$this->password)
$this->errorCode=self::ERROR_PASSWORD_INVALID;
else
{
$this->_id=$record->id;
$this->setState('name', $record->name);
$this->errorCode=self::ERROR_NONE;
}
return !$this->errorCode;
}
public function getId()
{
return $this->_id;
}
}