username, "@")) { $usuario = Usuario::model()->notsafe()->findByAttributes(array('email' => $this->username)); } else { $usuario = Usuario::model()->notsafe()->findByAttributes(array('username' => $this->username)); } if ($usuario === null) if (strpos($this->username, "@")) { $this->errorCode = self::ERROR_EMAIL_NOVALIDO; } else { $this->errorCode = self::ERROR_USERNAME_INVALID; } else if (Yii::app()->getModule('usuario')->encrypting($this->password) !== $usuario->password) $this->errorCode = self::ERROR_PASSWORD_INVALID; else if ($usuario->estado == 0 && Yii::app()->getModule('usuario')->loginNotActiv == false) $this->errorCode = self::ERROR_ESTADO_NOACTIVO; else if ($usuario->estado == -1) $this->errorCode = self::ERROR_ESTADO_BLOQUEADO; else { $this->_id = $usuario->id; $this->username = $usuario->username; $this->errorCode = self::ERROR_NONE; } return !$this->errorCode; } /** * @return integer the ID of the user record */ public function getId() { return $this->_id; } }