1***@qq.com
1***@qq.com
  • 发布:2025-05-22 19:26
  • 更新:2025-05-22 20:32
  • 阅读:133

Error: 权限校验未通过,未能获取当前用户信息,The login status is invalid, token has expired

分类:uniCloud

DB schema中配置:

"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"  
    }  
......  
"wx_openid": {  
            "bsonType": "object",  
            "description": "微信各个平台openid",  
            "properties": {  
                "app": {  
                    "bsonType": "string",  
                    "description": "app平台微信openid"  
                },  
                "mp": {  
                    "bsonType": "string",  
                    "description": "微信小程序平台openid"  
                },  
                "h5": {  
                    "bsonType": "string",  
                    "description": "微信公众号登录openid"  
                },  
                "web": {  
                    "bsonType": "string",  
                    "description": "PC页面扫码登录openid"  
                }  
            },  
            "permission": {  
                "read": true,  
                "write": true  
            }  
        }

云对象中部分代码:

const dbJQL = uniCloud.databaseForJQL({   
                clientInfo: this.getClientInfo()  
            })  

    let dbRes = await dbJQL.collection("uni-id-users").where({  
        'wx_openid.mp': openid  
    }).get();

提示错误:
12:51:24.065 [本地调试]Error: 权限校验未通过,未能获取当前用户信息,当前用户为匿名身份,请参考文档:https://uniapp.dcloud.net.cn/uniCloud/schema.html#handler-permission-error
12:51:24.065 [本地调试] at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
是什么原因?

2025-05-22 19:26 负责人:无 分享
已邀请:

最佳回复

DCloud_uniCloud_VK

DCloud_uniCloud_VK

因为uni-id-users表有字段级别的权限,比如password,token等等,所以无法这样查询,需要写明你要获取的字段名,然后字段名不可包含password等

如:

 let dbRes = await dbJQL.collection("uni-id-users").where({    
   'wx_openid.mp': openid    
 }).field({  
   '_id': true,   
   'nickname': true   
 }).get();
  • 1***@qq.com (作者)

    收到,感谢!!!

    2025-05-22 22:07

要回复问题请先登录注册