Login 密码错误时的yii登录功能

Login 密码错误时的yii登录功能,login,yii,Login,Yii,在yii中,我正在创建登录功能。当用户输入正确的用户名但密码错误时,我想在数据库中为这个正确的用户名设置serach,并想将该用户名的id放入LoginateMpt表中,并向他显示错误的密码消息。所以,请有人帮助我。在userIdentity.php中将数据保存在表中 public function authenticate() { $user = User::model()->findByAttributes(array('username' => $this->

在yii中,我正在创建登录功能。当用户输入正确的用户名但密码错误时,我想在数据库中为这个正确的用户名设置serach,并想将该用户名的id放入LoginateMpt表中,并向他显示错误的密码消息。所以,请有人帮助我。

在userIdentity.php中将数据保存在表中

  public function authenticate() {

    $user = User::model()->findByAttributes(array('username' => $this->username));

    if ($user === null) {
        $this->errorCode = self::ERROR_USERNAME_INVALID;
    } 

    elseif($user->password !== crypt($this->password, $salt))
    {    // save $user->id in attempt table here . 
            $this->errorCode = self::ERROR_PASSWORD_INVALID;

    }else{
     //set id 
  }
在文件中,身份验证函数被称为setError

$this->_identity = new UserIdentity($this->username, $this->password);
        if (!$this->_identity->authenticate())
            if ($this->_identity->errorCode === UserIdentity::ERROR_USERNAME_INVALID) {
                $this->addError('password', 'Incorrect email Id');
            }elseif($this->_identity->errorCode === UserIdentity::ERROR_PASSWORD_INVALID){
                $this->addError('password', 'Incorrect Password');
            }

我实现了相同的方法。我更改了可信方法,就像($user->password!==$user->encrypt($this->password)){this->errorCode=self::ERROR\u password\u无效;$command=Yii::app()->db->createCommand();$command->insert('trument',array('id'=>Yii::app()->user->getId(),);)但当密码错误时,则“Yii::app()->User->getId()”将不包含任何id。因为id字段仅在用户名和密码都正确时设置。如何获取该id以插入表中。如何在数据库中使用用户名进行搜索因为id未设置,您必须获取与用户名匹配的行,并将id保存在attemp表中为。$user=user::model()->findByAttributes(array('username'=>$this->username)); 这里$user->id是userid。保存在$this->\u id=//id中设置的相同变量;thanx很多先生…它起作用了。。。。现在我必须执行相同的登录功能。但我的客户端在extjs中,服务器端在yii框架中。使用extjs设计的登录页面将以Json格式发送用户名和密码。因此,如何更改登录方法以获得extjs以Json格式发送的用户名和密码。