姜同学
姜同学
  • 发布:2024-07-23 17:05
  • 更新:2024-07-24 08:03
  • 阅读:132

【报Bug】所有权限都开通了还是报错没有权限

分类:uniCloud

产品分类: uniCloud/App

示例代码:
// 文档教程: https://uniapp.dcloud.net.cn/uniCloud/schema  
{  
    "bsonType": "object",  
    "required": [],  
    "permission": {  
        "read": true,  
        "create": true,  
        "update": true,  
        "delete": true,  
        "count" : true  

    },  
    "properties": {  
        "_id": {  
            "description": "ID,系统自动生成"  
        },  
        "title": {  
            "title": "标题",  
            "description": "标题",  
            "bsonType": "string"  
        },  
        "user_uid": {  
            "title": "创建的人",  
            "description": "创建的人",  
            "bsonType": "string",  
            "defaultValue": {  
                "$env": "uid"  
            }  
        },  
        "customer":{  
            "title": "客户",  
            "bsonType": "array",  
            "description": "客户"  
        },  
        "authorityd": {  
            "title": "谁可以使用",  
            "description": "谁可以使用",  
            "bsonType": "array",  
            "arrayType": "string",  
            "foreignKey": "uni-id-users._id",  
            "enum": {  
                "collection": "uni-id-users",  
                "orderby": "value asc",  
                "field": "_id as value, nickname as text"  
            },  
            "componentForEdit":{  
                "name": "uni-data-checkbox"  
            }  
        },  
        "content":{  
            "title": "内容",  
            "description": "数据",  
            "bsonType": "array"  
        },  
        "makeMoney":{  
            "title": "制造费用",  
            "description": "制造费用",  
            "bsonType": "string"  
        },  
        "create_time": {  
            "title": "创建时间",  
            "description": "创建时间",  
            "bsonType": "timestamp",  
            "defaultValue": {  
                "$env": "now"  
            }  
        }  
    }  
}
// 文档教程: https://uniapp.dcloud.net.cn/uniCloud/schema  
{  
    "bsonType": "object",  
    "required": [],  
    "permission": {  
        "read": true,  
        "create": true,  
        "update": true,  
        "delete": true,  
        "count" : true  
    },  
    "properties": {  
        "_id": {  
            "description": "ID,系统自动生成",  
            "foreignKey": "table.customer"  
        },  
        "name":{  
            "title": "客户",  
            "description": "客户",  
            "bsonType": "string"  
        },  
        "create_time":{  
            "title": "时间",  
            "description": "时间",  
            "bsonType": "timestamp",  
            "defaultValue":{  
                "$env": "now"  
            }  
        }  

    }  
}

操作步骤:
import { enumConverter, filterToWhere } from '../../js_sdk/validator/client.js';  

  const db = uniCloud.database()  
  export default {  
    data() {  
      return {  
        collectionList: "client",  
        query: '',  
        where: '',  
        orderby: dbOrderBy,  
        orderByFieldName: "",  
        selectedIndexs: [],  
        options: {  
          pageSize,  
          pageCurrent,  
          filterData: {},  
          ...enumConverter  
        },  
        imageStyles: {  
          width: 64,  
          height: 64  
        },  
        exportExcel: {  
          "filename": "client.xls",  
          "type": "xls",  
          "fields": {  
            "客户": "name"  
          }  
        },  
        exportExcelData: []  
      }  
    },  
    onLoad() {  
      this._filter = {}  
    },  
    onReady() {  
      this.$refs.udb.loadData()  
    },  
    methods: {  
      search() {  
        const newWhere = this.getWhere()  
        // this.where = newWhere  
        let client = db.collection('client').where(newWhere).field('_id,name,create_time').orderBy("create_time","desc").getTemp();  
        let table = db.collection('table').where(`'${this.query.trim()}' in content`).field('customer,content').getTemp();  
        this.collectionList = [client,table];  

        this.$nextTick(() => {  
          this.loadData()  
        })  
      },

预期结果:

预期返回列表数据

实际结果:

实际返回

{  
    "code": "PERMISSION_ERROR",  
    "errCode": "PERMISSION_ERROR",  
    "message": "权限校验未通过,参与权限校验的集合:[client,table],请参考文档:https://uniapp.dcloud.net.cn/uniCloud/schema.html#handler-permission-error",  
    "errMsg": "权限校验未通过,参与权限校验的集合:[client,table],请参考文档:https://uniapp.dcloud.net.cn/uniCloud/schema.html#handler-permission-error",  
    "systemInfo": []  
}
"request": {  
          "method": "POST",  
          "url": "http://127.0.0.1:7000/cloudfunctions/DCloud-clientDB",  
          "httpVersion": "HTTP/1.1",  
          "headers": [  
            {  
              "name": "Accept",  
              "value": "*/*"  
            },  
            {  
              "name": "Accept-Encoding",  
              "value": "gzip, deflate, br, zstd"  
            },  
            {  
              "name": "Accept-Language",  
              "value": "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6"  
            },  
            {  
              "name": "Cache-Control",  
              "value": "no-cache"  
            },  
            {  
              "name": "Connection",  
              "value": "keep-alive"  
            },  
            {  
              "name": "Content-Length",  
              "value": "2237"  
            },  
            {  
              "name": "Content-Type",  
              "value": "application/json"  
            },  
            {  
              "name": "Host",  
              "value": "127.0.0.1:7000"  
            },  
            {  
              "name": "Origin",  
              "value": "http://localhost:5173"  
            },  
            {  
              "name": "Pragma",  
              "value": "no-cache"  
            },  
            {  
              "name": "Referer",  
              "value": "http://localhost:5173/"  
            },  
            {  
              "name": "Sec-Fetch-Dest",  
              "value": "empty"  
            },  
            {  
              "name": "Sec-Fetch-Mode",  
              "value": "cors"  
            },  
            {  
              "name": "Sec-Fetch-Site",  
              "value": "cross-site"  
            },  
            {  
              "name": "User-Agent",  
              "value": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36 Edg/126.0.0.0"  
            },  
            {  
              "name": "sec-ch-ua",  
              "value": "\"Not/A)Brand\";v=\"8\", \"Chromium\";v=\"126\", \"Microsoft Edge\";v=\"126\""  
            },  
            {  
              "name": "sec-ch-ua-mobile",  
              "value": "?0"  
            },  
            {  
              "name": "sec-ch-ua-platform",  
              "value": "\"Windows\""  
            }  
          ],  
          "queryString": [],  
          "cookies": [],  
          "headersSize": 718,  
          "bodySize": 2237,  
          "postData": {  
            "mimeType": "application/json",  
            "text": "{\"provider\":\"aliyun\",\"platform\":\"web\",\"param\":{\"command\":{\"$db\":[{\"$method\":\"collection\",\"$param\":[{\"$db\":[{\"$method\":\"collection\",\"$param\":[\"client\"]},{\"$method\":\"where\",\"$param\":[\"/张/i.test(name)\"]},{\"$method\":\"field\",\"$param\":[\"_id,name,create_time\"]},{\"$method\":\"orderBy\",\"$param\":[\"create_time\",\"desc\"]},{\"$method\":\"getTemp\",\"$param\":[]}]},{\"$db\":[{\"$method\":\"collection\",\"$param\":[\"table\"]},{\"$method\":\"where\",\"$param\":[\"'张' in content\"]},{\"$method\":\"field\",\"$param\":[\"customer,content\"]},{\"$method\":\"getTemp\",\"$param\":[]}]}]},{\"$method\":\"field\",\"$param\":[\"name\"]},{\"$method\":\"skip\",\"$param\":[0]},{\"$method\":\"limit\",\"$param\":[20]},{\"$method\":\"get\",\"$param\":[{\"getCount\":true}]}]},\"clientInfo\":{\"PLATFORM\":\"web\",\"OS\":\"windows\",\"APPID\":\"__UNI__BFD106F\",\"DEVICEID\":\"16750594632373900353\",\"scene\":1001,\"appId\":\"__UNI__BFD106F\",\"appLanguage\":\"zh-Hans\",\"appName\":\"云记录\",\"appVersion\":\"1.0.0\",\"appVersionCode\":\"100\",\"browserName\":\"edge\",\"browserVersion\":\"126.0.0.0\",\"deviceId\":\"16750594632373900353\",\"deviceModel\":\"PC\",\"deviceType\":\"pc\",\"hostName\":\"edge\",\"hostVersion\":\"126.0.0.0\",\"osName\":\"windows\",\"osVersion\":\"10 x64\",\"ua\":\"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36 Edg/126.0.0.0\",\"uniPlatform\":\"web\",\"uniRuntimeVersion\":\"4.24\",\"locale\":\"zh-Hans\",\"LOCALE\":\"zh-Hans\"},\"uniIdToken\":\"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1aWQiOiI2NjhmNGZhNzMzN2E5ZjNhMzM4N2JiNjUiLCJyb2xlIjpbImFkZFRhYmxlIiwiZGVsZXRlVGFibGUiLCJlZGl0VGFibGUiLCJ2aWV3VGFibGUiLCJhZG1pbmlzdHJhdG9yIl0sInBlcm1pc3Npb24iOlsiYWRkVGFibGUiLCJhZG1pbmlzdHJhdG9yIiwiQ1JFQVRFX1VOSV9JRF9VU0VSUyIsIlVQREFURV9VTklfSURfVVNFUlMiLCJSRUFEX1VOSV9JRF9VU0VSUyIsIkRFTEVURV9VTklfSURfVVNFUlMiLCJSRUFEX1VOSV9JRF9ST0xFUyIsIkNSRUFURV9VTklfSURfUk9MRVMiLCJVUERBVEVfVU5JX0lEX1JPTEVTIiwiREVMRVRFX1VOSV9JRF9ST0xFUyIsIlJFQURfVU5JX0lEX1RBRyIsIkNSRUFURV9VTklfSURfVEFHIiwiVVBEQVRFX1VOSV9JRF9UQUciLCJERUxFVEVfVU5JX0lEX1RBRyIsIlJFQURfT1BFTkRCX0FQUF9MSVNUIiwiQ1JFQVRFX09QRU5EQl9BUFBfTElTVCIsIlVQREFURV9PUEVOREJfQVBQX0xJU1QiLCJERUxFVEVfT1BFTkRCX0FQUF9MSVNUIiwiZWRpdFRhYmxlIiwidmlld1RhYmxlIiwiZGVsZXRlVGFibGUiXSwidW5pSWRWZXJzaW9uIjoiMS4wLjE3IiwiaWF0IjoxNzIxNzI1MDQ1LCJleHAiOjE3MjE3MzIyNDV9.08qW8uocHglovxELClX6YKZ8fhRlYJXAI-Uim2YSfwk\"}}"  
          }  
        },  
        "response": {  
          "status": 200,  
          "statusText": "OK",  
          "httpVersion": "HTTP/1.1",  
          "headers": [  
            {  
              "name": "Access-Control-Allow-Headers",  
              "value": "Origin, X-Requested-With, Content-Type, Accept"  
            },  
            {  
              "name": "Access-Control-Allow-Origin",  
              "value": "*"  
            },  
            {  
              "name": "Connection",  
              "value": "keep-alive"  
            },  
            {  
              "name": "Content-Length",  
              "value": "423"  
            },  
            {  
              "name": "Content-Type",  
              "value": "application/json;charset=UTF-8"  
            },  
            {  
              "name": "Date",  
              "value": "Tue, 23 Jul 2024 08:58:45 GMT"  
            },  
            {  
              "name": "Keep-Alive",  
              "value": "timeout=5"  
            }  
          ],  
          "cookies": [],  
          "content": {  
            "size": 423,  
            "mimeType": "application/json",  
            "compression": 0,  
            "text": "{\"code\":\"PERMISSION_ERROR\",\"errCode\":\"PERMISSION_ERROR\",\"message\":\"权限校验未通过,参与权限校验的集合:[client,table],请参考文档:https://uniapp.dcloud.net.cn/uniCloud/schema.html#handler-permission-error\",\"errMsg\":\"权限校验未通过,参与权限校验的集合:[client,table],请参考文档:https://uniapp.dcloud.net.cn/uniCloud/schema.html#handler-permission-error\",\"systemInfo\":[]}"  
          },  
          "redirectURL": "",  
          "headersSize": 280,  
          "bodySize": 423,  
          "_transferSize": 703,  
          "_error": null  
        },  
        "serverIPAddress": "127.0.0.1",  
        "startedDateTime": "2024-07-23T08:58:45.152Z",  
        "time": 509.7109999915119,  
        "timings": {  
          "blocked": 5.906000002594665,  
          "dns": -1,  
          "ssl": -1,  
          "connect": -1,  
          "send": 0.10099999999999998,  
          "wait": 502.3979999978989,  
          "receive": 1.305999991018325,  
          "_blocked_queueing": 4.736000002594665  
        }  
      },

bug描述:

所有表权限都开通了还是报错没有权限

2024-07-23 17:05 负责人:无 分享
已邀请:
套马杆的套子

套马杆的套子 - 没有解决不了的问题,只有解决不完的问题

给表中的字段也加上试试

"permission": {  
        "read": true,  
        "write": true  
      }

要回复问题请先登录注册