彗星
彗星
  • 发布:2025-05-20 18:25
  • 更新:2025-05-20 19:56
  • 阅读:157

bsonType 字段类型为password

分类:uniCloud

bsonType 字段类型为password
为什么一提交就告诉我权限校验未通过,未能获取当前用户信息,当前用户为匿名身份。
是什么原因?如何解决,谢谢了

2025-05-20 18:25 负责人:无 分享
已邀请:
DCloud_uniCloud_VK

DCloud_uniCloud_VK

发下提交数据库的代码怎么写

  • 彗星 (作者)

    // user-id.schema

    {

    "bsonType": "object",

    "required": [],

    "permission": {

    "read": true,

    "create": true,

    "update": true,

    "delete": true

    },

    "properties": {

    "_id": {

    "description": "ID,系统自动生成"

    },

    "username": {

    "bsonType": "string",

    "description": "用户名,不允许重复",

    "trim": "both"

    },

    "password": {

    "bsonType": "password",

    "description": "密码,加密存储",

    "trim": "both"

    },

    "nickname": {

    "bsonType": "string",

    "description": "用户昵称",

    "trim": "both"

    },

    "mobile": {

    "bsonType": "string",

    "description": "手机号码",

    "pattern": "^\+?[0-9-]{3,20}$",

    "trim": "both"

    },

    "register_date": {

    "bsonType": "timestamp",

    "description": "注册时间",

    "forceDefaultValue": {

    "$env": "now"

    }

    }

    }

    }

    2025-05-20 21:01

  • DCloud_uniCloud_VK

    回复 彗星: 数据库的add语句怎么写的

    2025-05-21 10:52

  • 彗星 (作者)

    回复 DCloud_uniCloud_VK: module.exports = {

    _before: function () { // 通用预处理器


    },  
    async add (e = {}) {
    const dbJQL = uniCloud.databaseForJQL({
    clientInfo:this.getClientInfo()
    });
    return await dbJQL.collection('muun').add(e)
    }

    }

    2025-05-22 09:56

  • 彗星 (作者)

    回复 DCloud_uniCloud_VK: 能帮我看看吗? 谢谢就是遇到password字段就权限不对

    2025-05-22 15:03

  • DCloud_uniCloud_VK

    回复 彗星: 你add的时候变量e不可包含password

    2025-05-22 18:08

  • DCloud_uniCloud_VK

    如果想添加password,就不要用JQL了

    2025-05-22 18:08

  • DCloud_uniCloud_VK

    const db = uniCloud.database()

    2025-05-22 18:09

要回复问题请先登录注册