l***@163.com
l***@163.com
  • 发布:2023-05-17 21:59
  • 更新:2023-09-18 17:04
  • 阅读:383

【报Bug】uni-id-pages 中的uni-id-users数据库,把read设置为true,可是提示:未能获取当前用户信息:当前用户为匿名身份

分类:uniCloud

产品分类: uniCloud/App

示例代码:

const dbJQL = uniCloud.databaseForJQL({
clientInfo: this.getClientInfo()
})
const collection = dbJQL.collection('uni-id-users')
const result = await collection.get({
getCount: true
})

uni-id-users

{
"bsonType": "object",
"required": [],
"permission": {
"read": true,
"create": true,
"update": true,
"delete": true
},
"properties": {
"_id": {
"description": "存储文档 ID(用户 ID),系统自动生成"
},
"avatar": {
"bsonType": "string",
"description": "头像地址",
"title": "头像地址",
"trim": "both"
},
"comment": {
"bsonType": "string",
"description": "备注",
"title": "备注",
"trim": "both"
},
"email": {
"bsonType": "string",
"description": "邮箱地址",
"format": "email",
"title": "邮箱",
"trim": "both"
},
"last_login_date": {
"bsonType": "timestamp",
"description": "最后登录时间"
},
"last_login_ip": {
"bsonType": "string",
"description": "最后登录时 IP 地址"
},
"mobile": {
"bsonType": "string",
"description": "手机号码",
"pattern": "^\+?[0-9-]{3,20}$",
"title": "手机号码",
"trim": "both"
},
"nickname": {
"bsonType": "string",
"description": "用户昵称",
"title": "昵称",
"trim": "both"
},
"password": {
"bsonType": "password",
"description": "密码,加密存储",
"title": "密码",
"trim": "both"
},
"register_date": {
"bsonType": "timestamp",
"description": "注册时间",
"forceDefaultValue": {
"$env": "now"
}
},
"roles": {
"bsonType": "array",
"description": "用户角色",
"enum": {
"collection": "uni-id-roles",
"field": "role_id as value, role_name as text"
},
"foreignKey": "uni-id-roles.role_id",
"title": "角色"
},
"status": {
"bsonType": "int",
"defaultValue": 0,
"description": "用户状态:0 正常 1 禁用 2 审核中 3 审核拒绝",
"enum": [
{
"text": "正常",
"value": 0
},
{
"text": "禁用",
"value": 1
},
{
"text": "审核中",
"value": 2
},
{
"text": "审核拒绝",
"value": 3
}
],
"title": "用户状态"
},
"token": {
"bsonType": "array",
"description": "用户token"
},
"username": {
"bsonType": "string",
"description": "用户名,不允许重复",
"title": "用户名",
"trim": "both"
}
}
}

uni-id-roles

{
"bsonType": "object",
"required": [
"role_id",
"role_name"
],
"permission": {
"read": true,
"create": true,
"update": true,
"delete": true
},
"properties": {
"_id": {
"description": "存储文档 ID,系统自动生成"
},
"comment": {
"title": "备注",
"bsonType": "string",
"description": "备注",
"trim": "both"
},
"create_date": {
"bsonType": "string",
"description": "创建时间"
},
"update_date": {
"bsonType": "string",
"description": "更新时间"
},
"role_id": {
"title": "唯一ID",
"bsonType": "string",
"description": "角色唯一标识,不可修改,不允许重复",
"trim": "both"
},
"name": {
"title": "名称",
"bsonType": "string"
},
"role_name": {
"title": "名称",
"bsonType": "string",
"description": "角色名称",
"trim": "both"
}
}
}

操作步骤:

预期结果:

正常获取所有用户列表

实际结果:

报错:未能获取当前用户信息:当前用户为匿名身份

bug描述:

【报Bug】uni-id-pages 中的uni-id-users数据库,我在schema中把permission都去掉了,而且把read设置为true,当我get数据库列表时候,提示:未能获取当前用户信息:当前用户为匿名身份

2023-05-17 21:59 负责人:无 分享
已邀请:
DCloud_uniCloud_CRL

DCloud_uniCloud_CRL

连接的是本地还是云端呢?云端的话有没有上传schema

  • 9***@qq.com

    我是连接的云端也上传了 schema,为什么还是报TOKEN_INVALID_ANONYMOUS_USER:未能获取当前用户信息:当前用户为匿名身份

    2023-08-17 17:11

1983年小巷

1983年小巷

"username": {
"bsonType": "string",
"description": "用户名,不允许重复",
"title": "用户名",
"trim": "both",
"permission": {
"read": true,
"write": "'CREATE_UNI_ID_USERS' in auth.permission || 'UPDATE_UNI_ID_USERS' in auth.permission"
}
},

把username的premission read改成true就可以了

要回复问题请先登录注册