c***@gmail.com
c***@gmail.com
  • 发布:2022-10-21 20:08
  • 更新:2022-10-24 14:35
  • 阅读:268

【报Bug】uni-id-pages 1.0.24,云函数/云对象在查询uni-id-users表的mobile等字段时,报错TOKEN_INVALID_ANONYMOUS_USER

分类:uniCloud

产品分类: uniCloud/腾讯云

示例代码:

在某个云函数中(运行时,选择连接云端云函数)调用某个云对象的如下方法:
getSmsEnabledMembers: async function() {
...
let sField = "_id,nickname,mobile";

    try {  
        let res = await dbJQL.collection('uni-id-users')  
            .field(sField)  
            .get();  
                    ....  
    } catch (err) {  
        ...  
    }  
            ...  

}

操作步骤:

不管是在HBuilder选择“上传并运行”云函数,还是定时运行该云函数,均报错。

预期结果:

得到uni-id-users表中的相关条目。

实际结果:

在日志中报错:
"运行出错 - " {"errMsg":"未能获取当前用户信息:当前用户为匿名身份","code":"TOKEN_INVALID_ANONYMOUS_USER","errCode":"TOKEN_INVALID_ANONYMOUS_USER"}

bug描述:

uni-id-pages 1.0.24中uni-id-users.schema.json的相关权限设置变更,导致若用云对象查询uni-id-users表的mobile等字段时,报错TOKEN_INVALID_ANONYMOUS_USER。
目前系统自带uni-id-users.schema.json的部分代码为:
"permission": {
"read": true,
"create": "'CREATE_UNI_ID_USERS' in auth.permission",
"update": "doc._id == auth.uid || 'UPDATE_UNI_ID_USERS' in auth.permission",
"delete": "'DELETE_UNI_ID_USERS' in auth.permission"
},

"properties": {
"mobile": {
"bsonType": "string",
"description": "手机号码",
"pattern": "^\+?[0-9-]{3,20}$",
"title": "手机号码",
"trim": "both",
"permission": {
"write": false,
"read": "doc._id == auth.uid"
}
},
...
}

而以前的uni-id-pages 1.0.14中运行正常,其uni-id-users.schema.json的相关权限设置为:
"permission": {
"update": "doc._id == auth.uid",
"read": "doc._id == auth.uid"
},

"properties": {
"mobile": {
"bsonType": "string",
"description": "手机号码",
"pattern": "^\+?[0-9-]{3,20}$",
"title": "手机号码",
"trim": "both",
"permission": {
"write": false
}
},
...
}

2022-10-21 20:08 负责人:无 分享
已邀请:
DCloud_uniCloud_WYQ

DCloud_uniCloud_WYQ

databaseForJQL方法传了什么参数?传clientInfo或者云函数的context了吗

  • 1***@qq.com

    请问云对象怎么传clientInfo

    2023-11-23 15:12

该问题目前已经被锁定, 无法添加新回复