Exemple #1
0
 public function authenticate()
 {
     Yii::log(__METHOD__, "info");
     $this->errorCode = self::ERROR_USERNAME_INVALID;
     $model = Yii::app()->user->um->loadUser($this->username);
     Yii::log(__METHOD__ . ' ' . CrugeTranslator::t('logger', 'Returned User') . ":\n" . CJSON::encode($model), "info");
     $this->_userinstance = null;
     if ($model != null) {
         if (CrugeUtil::checkhash($this->password, $model->password)) {
             $this->_userinstance = $model;
             $this->errorCode = self::ERROR_NONE;
         } else {
             if (CrugeUtil::config()->debug == true) {
                 // ayuda a instalar, quiza el usuario olvide quitar la encriptacion de claves
                 // y reciba error de ERROR_PASSWORD_INVALID, es porque esta actuando el Hash
                 // y el usuario recien creado trae una clave no encritpada
                 if (CrugeUtil::config()->useEncryptedPassword == true) {
                     echo Yii::app()->user->ui->setupAlert(CrugeTranslator::t('logon', 'Maybe your password doesn\'t match because you have set up \'useEncryptedPassword = true\' when you were installing Cruge, try \'false\' instead'));
                 }
             }
             $this->errorCode = self::ERROR_PASSWORD_INVALID;
         }
     } else {
         // username o email error
         $this->errorCode = self::ERROR_USERNAME_INVALID;
     }
     Yii::log(__CLASS__ . "\nauthenticate returns:\n" . $this->errorCode . "\n boolean result is:" . ($this->errorCode == self::ERROR_NONE), "info");
     return $this->errorCode == self::ERROR_NONE;
 }