Ejemplo n.º 1
0
 /**
  * Authenticates a user.
  * @return boolean whether authentication succeeds.
  */
 public function authenticate()
 {
     $user = ASystemUser::model()->find('LOWER(username)=?', array(strtolower($this->username)));
     //var_dump($user); exit();
     if ($user === null) {
         $this->errorCode = self::ERROR_USERNAME_INVALID;
     } else {
         if (!$user->validatePassword($this->password, Yii::app()->params->hashkey)) {
             $this->errorCode = self::ERROR_PASSWORD_INVALID;
         } else {
             $this->_id = $user->id;
             $this->_group_id = $user->group_id;
             $this->username = $user->username;
             $this->setState('role', $user->group_id);
             $this->errorCode = self::ERROR_NONE;
             //update login
         }
     }
     return $this->errorCode == self::ERROR_NONE;
 }
Ejemplo n.º 2
0
 public static function getUserNameById($id)
 {
     $criteria = new CDbCriteria();
     $criteria->select = 'username';
     $criteria->condition = 'id=:id';
     $criteria->params = array(':id' => (int) $id);
     $rs = ASystemUser::model()->find($criteria);
     /*
     $connection = Yii::app()->db;
     $sql = "SELECT username
             FROM {{system_user}}
             WHERE id = '".$id."'";
     $command = $connection->createCommand($sql);
     */
     //$rs = $command->queryRow();
     if (isset($rs) && $rs['username'] != '') {
         return $rs['username'];
     } else {
         return false;
     }
 }
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = ASystemUser::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Ejemplo n.º 4
0
 public function getSystemUserById($id)
 {
     return ASystemUser::model()->find('id=:id', array(':id' => $id));
 }