您好我通过数据库用户名和密码登录我的应用程序,我也想检查记住我复选框,但它没有设置我的用户名和密码。
'user' => array(
// enable cookie-based authentication
'allowAutoLogin'=>true,
),
main.php。
中的组件代码 public function login()
{
if($this->_identity===null)
{
$this->_identity=new UserIdentity($this->username,$this->password);
$this->_identity->authenticate();
}
if($this->_identity->errorCode===UserIdentity::ERROR_NONE)
{
$duration=$this->rememberMe ? 3600*24*30 : 0; // 30 days
Yii::app()->user->login($this->_identity,$duration);
return true;
}
else
return false;
}
public function authenticate()
{
// Create an instance from model Employee and search
$employee = Employee::model()->findByAttributes(array('email'=>$this->username));
//Swap original if(!isset($users[$this->username]))
if(!isset($employee->username))
$this->errorCode=self::ERROR_USERNAME_INVALID;
//Swap original elseif($users[$this->password]!==$this->password)
elseif($employee->password!=$this->password)
$this->errorCode=self::ERROR_PASSWORD_INVALID;
else
$this->errorCode=self::ERROR_NONE;
return !$this->errorCode;
}
帮助将不胜感激。