diff --git a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/common/utils.js b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/common/utils.js index 432404b933c7d23dc15fbc1947eb04310c6f0a6f..26092423744cc0767c4c4c379aa82fbc6895c647 100644 --- a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/common/utils.js +++ b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/common/utils.js @@ -171,6 +171,13 @@ function getNonceStr (length = 16) { return str.substring(0, length) } +try { + require('lodash.merge') +} catch (error) { + console.error('uni-id-co缺少依赖,请在uniCloud/cloudfunctions/common/uni-id-co目录执行 npm install 安装依赖') + throw error +} + module.exports = { getType, isValidString, diff --git a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/index.obj.js b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/index.obj.js index c8a3f112d87174a6cbcd080bf66168c2fc3a32fc..830fb19a532f23aae99b5f7b0d008b51317e94cf 100644 --- a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/index.obj.js +++ b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/index.obj.js @@ -217,6 +217,10 @@ module.exports = { * @param {String} params.nickname 昵称 * @param {Array} params.authorizedApp 允许登录的AppID列表 * @param {Array} params.role 用户角色列表 + * @param {String} params.mobile 手机号 + * @param {String} params.email 邮箱 + * @param {Array} params.tags 用户标签 + * @param {Number} params.status 用户状态 * @returns */ addUser, diff --git a/uni_modules/uni-id-pages/uniCloud/database/uni-id-users.schema.json b/uni_modules/uni-id-pages/uniCloud/database/uni-id-users.schema.json index 01addb8f6636864dce5e758a23ff4edc72becbb5..53cc584f1ae6823d49d021dd685e47a538a7d2ab 100644 --- a/uni_modules/uni-id-pages/uniCloud/database/uni-id-users.schema.json +++ b/uni_modules/uni-id-pages/uniCloud/database/uni-id-users.schema.json @@ -1,6 +1,5 @@ { "bsonType": "object", - "required": ["username", "password"], "permission": { "read": true, "create": "'CREATE_UNI_ID_USERS' in auth.permission", @@ -15,28 +14,36 @@ "bsonType": "string", "description": "支付宝平台openid", "permission": { - "write": false, - "read": "doc._id == auth.uid" + "read": "'READ_UNI_ID_USERS' in auth.permission", + "write": "'CREATE_UNI_ID_USERS' in auth.permission || 'UPDATE_UNI_ID_USERS' in auth.permission" } }, "apple_openid": { "bsonType": "string", "description": "苹果登录openid", "permission": { - "write": false, - "read": "doc._id == auth.uid" + "read": "'READ_UNI_ID_USERS' in auth.permission", + "write": "'CREATE_UNI_ID_USERS' in auth.permission || 'UPDATE_UNI_ID_USERS' in auth.permission" } }, "avatar": { "bsonType": "string", "description": "头像地址", "title": "头像地址", - "trim": "both" + "trim": "both", + "permission": { + "read": "doc._id == auth.uid || 'READ_UNI_ID_USERS' in auth.permission", + "write": "doc._id == auth.uid || 'CREATE_UNI_ID_USERS' in auth.permission || 'UPDATE_UNI_ID_USERS' in auth.permission" + } }, "avatar_file": { "bsonType": "file", "description": "用file类型方便使用uni-file-picker组件", - "title": "头像文件" + "title": "头像文件", + "permission": { + "read": "doc._id == auth.uid || 'READ_UNI_ID_USERS' in auth.permission", + "write": "doc._id == auth.uid || 'CREATE_UNI_ID_USERS' in auth.permission || 'UPDATE_UNI_ID_USERS' in auth.permission" + } }, "comment": { "bsonType": "string", @@ -44,8 +51,8 @@ "title": "备注", "trim": "both", "permission": { - "write": false, - "read": false + "read": "'READ_UNI_ID_USERS' in auth.permission", + "write": "'CREATE_UNI_ID_USERS' in auth.permission || 'UPDATE_UNI_ID_USERS' in auth.permission" } }, "dcloud_appid": { @@ -53,8 +60,8 @@ "description": "允许登录的客户端的appid列表", "foreignKey": "opendb-app-list.appid", "permission": { - "write": false, - "read": "doc._id == auth.uid" + "read": "'READ_UNI_ID_USERS' in auth.permission", + "write": "'CREATE_UNI_ID_USERS' in auth.permission || 'UPDATE_UNI_ID_USERS' in auth.permission" } }, "department_id": { @@ -68,8 +75,8 @@ "enumType": "tree", "title": "部门", "permission": { - "write": false, - "read": "doc._id == auth.uid" + "read": "doc._id == auth.uid || 'READ_UNI_ID_USERS' in auth.permission", + "write": "'CREATE_UNI_ID_USERS' in auth.permission || 'UPDATE_UNI_ID_USERS' in auth.permission" } }, "email": { @@ -79,8 +86,8 @@ "title": "邮箱", "trim": "both", "permission": { - "write": false, - "read": "doc._id == auth.uid" + "read": "doc._id == auth.uid || 'READ_UNI_ID_USERS' in auth.permission", + "write": "'CREATE_UNI_ID_USERS' in auth.permission || 'UPDATE_UNI_ID_USERS' in auth.permission" } }, "email_confirmed": { @@ -98,8 +105,8 @@ ], "title": "邮箱验证状态", "permission": { - "write": false, - "read": "doc._id == auth.uid" + "read": "doc._id == auth.uid || 'READ_UNI_ID_USERS' in auth.permission", + "write": "'CREATE_UNI_ID_USERS' in auth.permission || 'UPDATE_UNI_ID_USERS' in auth.permission" } }, "gender": { @@ -121,16 +128,16 @@ ], "title": "性别", "permission": { - "write": false, - "read": "doc._id == auth.uid" + "read": "doc._id == auth.uid || 'READ_UNI_ID_USERS' in auth.permission", + "write": "'CREATE_UNI_ID_USERS' in auth.permission || 'UPDATE_UNI_ID_USERS' in auth.permission" } }, "invite_time": { "bsonType": "timestamp", "description": "受邀时间", "permission": { - "write": false, - "read": "doc._id == auth.uid" + "read": "doc._id == auth.uid || 'READ_UNI_ID_USERS' in auth.permission", + "write": "'CREATE_UNI_ID_USERS' in auth.permission || 'UPDATE_UNI_ID_USERS' in auth.permission" } }, "inviter_uid": { @@ -138,24 +145,24 @@ "description": "用户全部上级邀请者", "trim": "both", "permission": { - "write": false, - "read": "doc._id == auth.uid" + "read": "doc._id == auth.uid || 'READ_UNI_ID_USERS' in auth.permission", + "write": "'CREATE_UNI_ID_USERS' in auth.permission || 'UPDATE_UNI_ID_USERS' in auth.permission" } }, "last_login_date": { "bsonType": "timestamp", "description": "最后登录时间", "permission": { - "write": false, - "read": "doc._id == auth.uid" + "read": "doc._id == auth.uid || 'READ_UNI_ID_USERS' in auth.permission", + "write": "'CREATE_UNI_ID_USERS' in auth.permission || 'UPDATE_UNI_ID_USERS' in auth.permission" } }, "last_login_ip": { "bsonType": "string", "description": "最后登录时 IP 地址", "permission": { - "write": false, - "read": "doc._id == auth.uid" + "read": "doc._id == auth.uid || 'READ_UNI_ID_USERS' in auth.permission", + "write": "'CREATE_UNI_ID_USERS' in auth.permission || 'UPDATE_UNI_ID_USERS' in auth.permission" } }, "mobile": { @@ -165,8 +172,8 @@ "title": "手机号码", "trim": "both", "permission": { - "write": false, - "read": "doc._id == auth.uid" + "read": "doc._id == auth.uid || 'READ_UNI_ID_USERS' in auth.permission", + "write": "'CREATE_UNI_ID_USERS' in auth.permission || 'UPDATE_UNI_ID_USERS' in auth.permission" } }, "mobile_confirmed": { @@ -184,49 +191,49 @@ ], "title": "手机号验证状态", "permission": { - "write": false, - "read": "doc._id == auth.uid" + "read": "doc._id == auth.uid || 'READ_UNI_ID_USERS' in auth.permission", + "write": "'CREATE_UNI_ID_USERS' in auth.permission || 'UPDATE_UNI_ID_USERS' in auth.permission" } }, "my_invite_code": { "bsonType": "string", "description": "用户自身邀请码", "permission": { - "write": false, - "read": "doc._id == auth.uid" + "read": "doc._id == auth.uid || 'READ_UNI_ID_USERS' in auth.permission", + "write": "'CREATE_UNI_ID_USERS' in auth.permission || 'UPDATE_UNI_ID_USERS' in auth.permission" } }, "nickname": { "bsonType": "string", "description": "用户昵称", "title": "昵称", - "trim": "both" + "trim": "both", + "permission": { + "read": "doc._id == auth.uid || 'READ_UNI_ID_USERS' in auth.permission", + "write": "doc._id == auth.uid || 'CREATE_UNI_ID_USERS' in auth.permission || 'UPDATE_UNI_ID_USERS' in auth.permission" + } }, "password": { "bsonType": "password", "description": "密码,加密存储", "title": "密码", - "trim": "both", - "permission": { - "write": false, - "read": false - } + "trim": "both" }, "password_secret_version": { "bsonType": "int", "description": "密码使用的passwordSecret版本", "title": "passwordSecret", "permission": { - "write": false, - "read": false + "read": false, + "write": false } }, "realname_auth": { "bsonType": "object", "description": "实名认证信息", "permission": { - "write": false, - "read": "doc._id == auth.uid" + "read": "doc._id == auth.uid || 'READ_UNI_ID_USERS' in auth.permission", + "write": "'CREATE_UNI_ID_USERS' in auth.permission || 'UPDATE_UNI_ID_USERS' in auth.permission" }, "properties": { "auth_date": { @@ -291,16 +298,22 @@ "bsonType": "timestamp", "description": "注册时间", "forceDefaultValue": { - "$env": "now", - "read": "doc._id == auth.uid" + "$env": "now" + }, + "permission": { + "read": "doc._id == auth.uid || 'READ_UNI_ID_USERS' in auth.permission", + "write": "'CREATE_UNI_ID_USERS' in auth.permission || 'UPDATE_UNI_ID_USERS' in auth.permission" } }, "register_ip": { "bsonType": "string", "description": "注册时 IP 地址", "forceDefaultValue": { - "$env": "clientIP", - "read": "doc._id == auth.uid" + "$env": "clientIP" + }, + "permission": { + "read": "doc._id == auth.uid || 'READ_UNI_ID_USERS' in auth.permission", + "write": "'CREATE_UNI_ID_USERS' in auth.permission || 'UPDATE_UNI_ID_USERS' in auth.permission" } }, "role": { @@ -312,8 +325,8 @@ }, "foreignKey": "uni-id-roles.role_id", "permission": { - "write": false, - "read": "doc._id == auth.uid" + "read": "doc._id == auth.uid || 'READ_UNI_ID_USERS' in auth.permission", + "write": "'CREATE_UNI_ID_USERS' in auth.permission || 'UPDATE_UNI_ID_USERS' in auth.permission" }, "title": "角色" }, @@ -321,8 +334,8 @@ "bsonType": "int", "description": "用户积分,积分变更记录可参考:uni-id-scores表定义", "permission": { - "write": false, - "read": "doc._id == auth.uid" + "read": "doc._id == auth.uid || 'READ_UNI_ID_USERS' in auth.permission", + "write": "'CREATE_UNI_ID_USERS' in auth.permission || 'UPDATE_UNI_ID_USERS' in auth.permission" } }, "status": { @@ -330,8 +343,8 @@ "defaultValue": 0, "description": "用户状态:0 正常 1 禁用 2 审核中 3 审核拒绝", "permission": { - "write": false, - "read": "doc._id == auth.uid" + "read": "doc._id == auth.uid || 'READ_UNI_ID_USERS' in auth.permission", + "write": "'CREATE_UNI_ID_USERS' in auth.permission || 'UPDATE_UNI_ID_USERS' in auth.permission" }, "enum": [{ "text": "正常", @@ -356,7 +369,8 @@ "bsonType": "array", "description": "用户token", "permission": { - "read": "doc._id == auth.uid" + "read": "'READ_UNI_ID_USERS' in auth.permission", + "write": "'CREATE_UNI_ID_USERS' in auth.permission || 'UPDATE_UNI_ID_USERS' in auth.permission" } }, "username": { @@ -365,7 +379,8 @@ "title": "用户名", "trim": "both", "permission": { - "write": false + "read": "doc._id == auth.uid || 'READ_UNI_ID_USERS' in auth.permission", + "write": "'CREATE_UNI_ID_USERS' in auth.permission || 'UPDATE_UNI_ID_USERS' in auth.permission" } }, "wx_openid": { @@ -390,16 +405,16 @@ } }, "permission": { - "write": false, - "read": "doc._id == auth.uid" + "read": "'READ_UNI_ID_USERS' in auth.permission", + "write": "'CREATE_UNI_ID_USERS' in auth.permission || 'UPDATE_UNI_ID_USERS' in auth.permission" } }, "wx_unionid": { "bsonType": "string", "description": "微信unionid", "permission": { - "write": false, - "read": "doc._id == auth.uid" + "read": "'READ_UNI_ID_USERS' in auth.permission", + "write": "'CREATE_UNI_ID_USERS' in auth.permission || 'UPDATE_UNI_ID_USERS' in auth.permission" } }, "qq_openid": { @@ -416,17 +431,26 @@ } }, "permission": { - "write": false, - "read": "doc._id == auth.uid" + "read": "'READ_UNI_ID_USERS' in auth.permission", + "write": "'CREATE_UNI_ID_USERS' in auth.permission || 'UPDATE_UNI_ID_USERS' in auth.permission" } }, "qq_unionid": { "bsonType": "string", "description": "QQ unionid", "permission": { - "write": false, - "read": "doc._id == auth.uid" + "read": "'READ_UNI_ID_USERS' in auth.permission", + "write": "'CREATE_UNI_ID_USERS' in auth.permission || 'UPDATE_UNI_ID_USERS' in auth.permission" + } + }, + "third_party": { + "bsonType": "object", + "description": "三方平台凭证", + "permission": { + "read": false, + "write": false } } - } + }, + "required": [] } \ No newline at end of file