Example #1
0
 public function authenticate()
 {
     $record = TblUser::model()->findByAttributes(array('name' => $this->username));
     //print_r($record);
     if ($record === null) {
         $this->errorCode = self::ERROR_USERNAME_INVALID;
     } else {
         if ($record->password !== md5($this->password . $record->salt)) {
             $this->errorCode = self::ERROR_PASSWORD_INVALID;
         } else {
             $this->_id = $record->uid;
             $this->setState('name', $record->name);
             $this->errorCode = self::ERROR_NONE;
         }
     }
     return !$this->errorCode;
 }
Example #2
0
 /**
  * Authenticates a user.
  * The example implementation makes sure if the username and password
  * are both 'demo'.
  * In practical applications, this should be changed to authenticate
  * against some persistent user identity storage (e.g. database).
  * @return boolean whether authentication succeeds.
  */
 public function authenticate()
 {
     /* $users=array(
     			// username => password
     			'demo'=>'demo',
     			'admin'=>'admin',
     		); */
     $record = TblUser::model()->findByAttributes(array('username' => $this->username));
     if ($record === null) {
         $this->errorCode = self::ERROR_USERNAME_INVALID;
     } else {
         if ($record->password !== $this->password) {
             $this->errorCode = self::ERROR_PASSWORD_INVALID;
         } else {
             $this->errorCode = self::ERROR_NONE;
         }
     }
     return !$this->errorCode;
 }
Example #3
0
 public function actionUser()
 {
     $res = TblUser::getUser();
     var_dump($res);
 }
Example #4
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getTblUsers()
 {
     return $this->hasMany(TblUser::className(), ['status_id' => 'id']);
 }
 private static function findAllAdminTblUser(TblUser $tblUser)
 {
     $options = array('fields' => array('user_mail'), 'conditions' => array('mst_user_group_id' => MstUserGroup::ID_ADMIN), 'recursive' => -1);
     return $tblUser->find('all', $options);
 }
 /**
  * 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 $id the ID of the model to be loaded
  * @return TblUser the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = TblUser::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Example #7
0
 private static function findTblUser(TblUser $tblUser, $tbl_user_id)
 {
     return $tblUser->read(null, $tbl_user_id);
 }
Example #8
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getAuthor()
 {
     return $this->hasOne(TblUser::className(), ['id' => 'author_id']);
 }