Exemplo n.º 1
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()
 {
     $record = TSUser::model()->findByAttributes(array('User_Name' => $this->username));
     if ($record === null) {
         $this->errorCode = self::ERROR_USERNAME_INVALID;
     } else {
         if ($record->Password !== md5($this->password)) {
             $this->errorCode = self::ERROR_PASSWORD_INVALID;
         } else {
             $this->_id = $record->ID;
             $this->errorCode = self::ERROR_NONE;
         }
     }
     return !$this->errorCode;
 }
Exemplo n.º 2
0
 public function actionDeleteUser()
 {
     try {
         $ids = yii::app()->request->getParam('ids');
         $count = TSUser::model()->deleteAll('Id in (' . $ids . ')');
         if ($count > 0) {
             echo json_encode(array('flag' => 'SUCCESS', 'message' => '删除成功!'), JSON_UNESCAPED_UNICODE);
         } else {
             echo json_encode(array('flag' => 'SUCCESS', 'message' => '删除失败!'), JSON_UNESCAPED_UNICODE);
         }
     } catch (Exception $e) {
         echo json_decode(array('flag' => 'Exception', 'message' => $e->getMessage()), JSON_UNESCAPED_UNICODE);
     }
 }