3
데이터베이스에 문의하지 않고 yii
에서 지정된 사용자 이름으로 사용자를 인증하도록 강제 설정해야합니까?Yii : 강제 인증
내 앱에서 로그인 할 때 api
을 사용하고 api
이 기록되지 않을 때까지 app
을 사용할 수 없습니다. User::model()
public function authenticate()
{
if (strpos($this->username,"@")) {
$user=User::model()->findByAttributes(array('email'=>$this->username));
} else {
$user=User::model()->findByAttributes(array('username'=>$this->username));
}
if($user===null)
if (strpos($this->username,"@")) {
$this->errorCode=self::ERROR_EMAIL_INVALID;
} else {
$this->errorCode=self::ERROR_USERNAME_INVALID;
}
else if(Yii::app()->getModule('user')->encrypting($this->password)!==$user->password)
$this->errorCode=self::ERROR_PASSWORD_INVALID;
else if($user->active==0&&Yii::app()->getModule('user')->loginNotActiv==false)
$this->errorCode=self::ERROR_STATUS_NOTACTIV;
else if($user->active==-1)
$this->errorCode=self::ERROR_STATUS_BAN;
else {
$this->_id=$user->id;
$this->errorCode=self::ERROR_NONE;
$user->saveState($this);
}
return !$this->errorCode;
}