1***@qq.com
1***@qq.com
  • 发布:2022-09-23 16:50
  • 更新:2022-09-25 12:18
  • 阅读:62

#插件讨论# 【 uni-admin 基础框架 - DCloud前端团队 】权限校验未通过

分类:uniCloud
关联插件: uni-admin 基础框架

新建项目uni-admin,设置一个测试用户,把所需要的表schema权限全部设置为ture,登录此测试用户还是提示 权限校验未通过

下面是请求的载荷

{"method":"serverless.function.runtime.invoke","params":"{\"functionTarget\":\"DCloud-clientDB\",\"functionArgs\":{\"command\":{\"$db\":[{\"$method\":\"collection\",\"$param\":[\"uni-id-users,uni-id-roles\"]},{\"$method\":\"field\",\"$param\":[\"username,nickname,mobile,status,email,role{role_name},dcloud_appid,tags,last_login_date\"]},{\"$method\":\"orderBy\",\"$param\":[\"last_login_date desc\"]},{\"$method\":\"skip\",\"$param\":[0]},{\"$method\":\"limit\",\"$param\":[20]},{\"$method\":\"get\",\"$param\":[{\"getCount\":true}]}]},\"clientInfo\":{\"PLATFORM\":\"web\",\"OS\":\"windows\",\"APPID\":\"__UNI__5C75219\",\"DEVICEID\":\"16602720696954396880\",\"scene\":1001,\"appId\":\"__UNI__5C75219\",\"appLanguage\":\"zh-Hans\",\"appName\":\"ailianmeng-admin\",\"appVersion\":\"1.0.0\",\"appVersionCode\":\"100\",\"browserName\":\"chrome\",\"browserVersion\":\"105.0.0.0\",\"deviceId\":\"16602720696954396880\",\"deviceModel\":\"PC\",\"deviceOrientation\":\"portrait\",\"devicePixelRatio\":1,\"deviceType\":\"pc\",\"hostLanguage\":\"zh-CN\",\"hostName\":\"chrome\",\"hostVersion\":\"105.0.0.0\",\"osName\":\"windows\",\"osVersion\":\"10 x64\",\"safeArea\":{\"left\":0,\"right\":1458,\"top\":0,\"bottom\":979,\"width\":1458,\"height\":979},\"safeAreaInsets\":{\"top\":0,\"right\":0,\"bottom\":0,\"left\":0},\"screenHeight\":1080,\"screenWidth\":1920,\"statusBarHeight\":0,\"ua\":\"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36\",\"uniCompileVersion\":\"3.6.3\",\"uniPlatform\":\"web\",\"uniRuntimeVersion\":\"3.6.3\",\"windowBottom\":0,\"windowHeight\":979,\"windowTop\":0,\"windowWidth\":1458,\"locale\":\"zh-Hans\",\"LOCALE\":\"zh-Hans\"},\"uniIdToken\":\"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1aWQiOiI2MzJkMWNiY2ZjZjRhMzAwMDFlM2MwYTAiLCJyb2xlIjpbInRlc3QiXSwicGVybWlzc2lvbiI6WyJSRUFEX1VOSV9JRF9ST0xFUyJdLCJ1bmlJZFZlcnNpb24iOiIxLjAuMTMiLCJpYXQiOjE2NjM5MjI2NjEsImV4cCI6MTY2MzkyOTg2MX0.tQFTJIh6tsReyQffmtpb-xf3wpa5DU-XA1_QmwggP_M\"}}","spaceId":"482734c0-a834-4818-bc32-180fd1f3879d","timestamp":1663922943813,"token":"6a9d8d22-94bc-44e6-b359-21158f06a562"}
2022-09-23 16:50 负责人:无 分享
已邀请:
DCloud_uniCloud_WYQ

DCloud_uniCloud_WYQ

把完整的uni-id-users的schema发出来看一下

  • 1***@qq.com (作者)

    就是新建的项目 啥都没改呀 按文档流程来的 schema我发在下一条评论了 麻烦帮忙看看问题

    2022-09-25 12:18

1***@qq.com

1***@qq.com (作者)

{  
    "bsonType": "object",  
    "required": ["username", "password"],  
    "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": {  
        "_id": {  
            "description": "存储文档 ID(用户 ID),系统自动生成"  
        },  
        "ali_openid": {  
            "bsonType": "string",  
            "description": "支付宝平台openid",  
            "permission": {  
                "write": false,  
                "read": "doc._id == auth.uid"  
            }  
        },  
        "apple_openid": {  
            "bsonType": "string",  
            "description": "苹果登录openid",  
            "permission": {  
                "write": false,  
                "read": "doc._id == auth.uid"  
            }  
        },  
        "avatar": {  
            "bsonType": "string",  
            "description": "头像地址",  
            "title": "头像地址",  
            "trim": "both"  
        },  
        "avatar_file": {  
            "bsonType": "file",  
            "description": "用file类型方便使用uni-file-picker组件",  
            "title": "头像文件"  
        },  
        "comment": {  
            "bsonType": "string",  
            "description": "备注",  
            "title": "备注",  
            "trim": "both",  
            "permission": {  
                "write": false,  
                "read": false  
            }  
        },  
        "dcloud_appid": {  
            "bsonType": "array",  
            "description": "允许登录的客户端的appid列表",  
            "foreignKey": "opendb-app-list.appid",  
            "permission": {  
                "write": false,  
                "read": "doc._id == auth.uid"  
            }  
        },  
        "department_id": {  
            "bsonType": "array",  
            "description": "部门ID",  
            "enum": {  
                "collection": "opendb-department",  
                "field": "_id as value, name as text",  
                "orderby": "name asc"  
            },  
            "enumType": "tree",  
            "title": "部门",  
            "permission": {  
                "write": false,  
                "read": "doc._id == auth.uid"  
            }  
        },  
        "email": {  
            "bsonType": "string",  
            "description": "邮箱地址",  
            "format": "email",  
            "title": "邮箱",  
            "trim": "both",  
            "permission": {  
                "write": false,  
                "read": "doc._id == auth.uid"  
            }  
        },  
        "email_confirmed": {  
            "bsonType": "int",  
            "defaultValue": 0,  
            "description": "邮箱验证状态:0 未验证 1 已验证",  
            "enum": [{  
                    "text": "未验证",  
                    "value": 0  
                },  
                {  
                    "text": "已验证",  
                    "value": 1  
                }  
            ],  
            "title": "邮箱验证状态",  
            "permission": {  
                "write": false,  
                "read": "doc._id == auth.uid"  
            }  
        },  
        "gender": {  
            "bsonType": "int",  
            "defaultValue": 0,  
            "description": "用户性别:0 未知 1 男性 2 女性",  
            "enum": [{  
                    "text": "未知",  
                    "value": 0  
                },  
                {  
                    "text": "男",  
                    "value": 1  
                },  
                {  
                    "text": "女",  
                    "value": 2  
                }  
            ],  
            "title": "性别",  
            "permission": {  
                "write": false,  
                "read": "doc._id == auth.uid"  
            }  
        },  
        "invite_time": {  
            "bsonType": "timestamp",  
            "description": "受邀时间",  
            "permission": {  
                "write": false,  
                "read": "doc._id == auth.uid"  
            }  
        },  
        "inviter_uid": {  
            "bsonType": "array",  
            "description": "用户全部上级邀请者",  
            "trim": "both",  
            "permission": {  
                "write": false,  
                "read": "doc._id == auth.uid"  
            }  
        },  
        "last_login_date": {  
            "bsonType": "timestamp",  
            "description": "最后登录时间",  
            "permission": {  
                "write": false,  
                "read": "doc._id == auth.uid"  
            }  
        },  
        "last_login_ip": {  
            "bsonType": "string",  
            "description": "最后登录时 IP 地址",  
            "permission": {  
                "write": false,  
                "read": "doc._id == auth.uid"  
            }  
        },  
        "mobile": {  
            "bsonType": "string",  
            "description": "手机号码",  
            "pattern": "^\\+?[0-9-]{3,20}$",  
            "title": "手机号码",  
            "trim": "both",  
            "permission": {  
                "write": false,  
                "read": "doc._id == auth.uid"  
            }  
        },  
        "mobile_confirmed": {  
            "bsonType": "int",  
            "defaultValue": 0,  
            "description": "手机号验证状态:0 未验证 1 已验证",  
            "enum": [{  
                    "text": "未验证",  
                    "value": 0  
                },  
                {  
                    "text": "已验证",  
                    "value": 1  
                }  
            ],  
            "title": "手机号验证状态",  
            "permission": {  
                "write": false,  
                "read": "doc._id == auth.uid"  
            }  
        },  
        "my_invite_code": {  
            "bsonType": "string",  
            "description": "用户自身邀请码",  
            "permission": {  
                "write": false,  
                "read": "doc._id == auth.uid"  
            }  
        },  
        "nickname": {  
            "bsonType": "string",  
            "description": "用户昵称",  
            "title": "昵称",  
            "trim": "both"  
        },  
        "password": {  
            "bsonType": "password",  
            "description": "密码,加密存储",  
            "title": "密码",  
            "trim": "both",  
            "permission": {  
                "write": false,  
                "read": false  
            }  
        },  
        "password_secret_version": {  
            "bsonType": "int",  
            "description": "密码使用的passwordSecret版本",  
            "title": "passwordSecret",  
            "permission": {  
                "write": false,  
                "read": false  
            }  
        },  
        "realname_auth": {  
            "bsonType": "object",  
            "description": "实名认证信息",  
            "permission": {  
                "write": false,  
                "read": "doc._id == auth.uid"  
            },  
            "properties": {  
                "auth_date": {  
                    "bsonType": "timestamp",  
                    "description": "认证通过时间"  
                },  
                "auth_status": {  
                    "bsonType": "int",  
                    "description": "认证状态:0 未认证 1 等待认证 2 认证通过 3 认证失败",  
                    "maximum": 3,  
                    "minimum": 0  
                },  
                "contact_email": {  
                    "bsonType": "string",  
                    "description": "联系人邮箱"  
                },  
                "contact_mobile": {  
                    "bsonType": "string",  
                    "description": "联系人手机号码"  
                },  
                "contact_person": {  
                    "bsonType": "string",  
                    "description": "联系人姓名"  
                },  
                "id_card_back": {  
                    "bsonType": "string",  
                    "description": "身份证反面照 URL"  
                },  
                "id_card_front": {  
                    "bsonType": "string",  
                    "description": "身份证正面照 URL"  
                },  
                "identity": {  
                    "bsonType": "string",  
                    "description": "身份证号码/营业执照号码"  
                },  
                "in_hand": {  
                    "bsonType": "string",  
                    "description": "手持身份证照片 URL"  
                },  
                "license": {  
                    "bsonType": "string",  
                    "description": "营业执照 URL"  
                },  
                "real_name": {  
                    "bsonType": "string",  
                    "description": "真实姓名/企业名称"  
                },  
                "type": {  
                    "bsonType": "int",  
                    "description": "用户类型:0 个人用户 1 企业用户",  
                    "maximum": 1,  
                    "minimum": 0  
                }  
            },  
            "required": [  
                "type",  
                "auth_status"  
            ]  
        },  
        "register_date": {  
            "bsonType": "timestamp",  
            "description": "注册时间",  
            "forceDefaultValue": {  
                "$env": "now",  
                "read": "doc._id == auth.uid"  
            }  
        },  
        "register_ip": {  
            "bsonType": "string",  
            "description": "注册时 IP 地址",  
            "forceDefaultValue": {  
                "$env": "clientIP",  
                "read": "doc._id == auth.uid"  
            }  
        },  
        "role": {  
            "bsonType": "array",  
            "description": "用户角色",  
            "enum": {  
                "collection": "uni-id-roles",  
                "field": "role_id as value, role_name as text"  
            },  
            "foreignKey": "uni-id-roles.role_id",  
            "permission": {  
                "write": false,  
                "read": "doc._id == auth.uid"  
            },  
            "title": "角色"  
        },  
        "score": {  
            "bsonType": "int",  
            "description": "用户积分,积分变更记录可参考:uni-id-scores表定义",  
            "permission": {  
                "write": false,  
                "read": "doc._id == auth.uid"  
            }  
        },  
        "status": {  
            "bsonType": "int",  
            "defaultValue": 0,  
            "description": "用户状态:0 正常 1 禁用 2 审核中 3 审核拒绝",  
            "permission": {  
                "write": false,  
                "read": "doc._id == auth.uid"  
            },  
            "enum": [{  
                    "text": "正常",  
                    "value": 0  
                },  
                {  
                    "text": "禁用",  
                    "value": 1  
                },  
                {  
                    "text": "审核中",  
                    "value": 2  
                },  
                {  
                    "text": "审核拒绝",  
                    "value": 3  
                }  
            ],  
            "title": "用户状态"  
        },  
        "token": {  
            "bsonType": "array",  
            "description": "用户token",  
            "permission": {  
                "read": "doc._id == auth.uid"  
            }  
        },  
        "username": {  
            "bsonType": "string",  
            "description": "用户名,不允许重复",  
            "title": "用户名",  
            "trim": "both",  
            "permission": {  
                "write": false  
            }  
        },  
        "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": {  
                "write": false,  
                "read": "doc._id == auth.uid"  
            }  
        },  
        "wx_unionid": {  
            "bsonType": "string",  
            "description": "微信unionid",  
            "permission": {  
                "write": false,  
                "read": "doc._id == auth.uid"  
            }  
        },  
        "qq_openid": {  
            "bsonType": "object",  
            "description": "QQ各个平台openid",  
            "properties": {  
                "app": {  
                    "bsonType": "string",  
                    "description": "app平台QQ openid"  
                },  
                "mp": {  
                    "bsonType": "string",  
                    "description": "QQ小程序平台openid"  
                }  
            },  
            "permission": {  
                "write": false,  
                "read": "doc._id == auth.uid"  
            }  
        },  
        "qq_unionid": {  
            "bsonType": "string",  
            "description": "QQ unionid",  
            "permission": {  
                "write": false,  
                "read": "doc._id == auth.uid"  
            }  
        }  
    }  
}  
  • DCloud_uniCloud_WYQ

    email权限配置的是仅当前用户可读

    2022-09-26 11:42

  • 1***@qq.com (作者)

    回复 DCloud_uniCloud_WYQ: 列表数据不能看到当前登录的用户吗?

    2022-09-26 14:21

  • DCloud_uniCloud_WYQ

    回复 1***@qq.com: 稍等,uni-id-pages里面的uni-id-users的schema不是最新的。我们调整下,可以先参考: uni-id-users权限调整

    2022-09-26 14:43

  • 1***@qq.com (作者)

    回复 DCloud_uniCloud_WYQ: 还请教一个问题,就是admin项目的schema权限都配置好了权限ID,比如CREATE_UNI_ID_USERS,DELETE_UNI_ID_USERS等,那如果要添加一个拥有所有权限的用户,是不是需要把schema中配置好的权限ID全部创建,再添加到该用户账号上?

    2022-09-26 14:52

  • DCloud_uniCloud_WYQ

    回复 1***@qq.com: 是的,权限和用户中间还有一层角色

    2022-09-26 19:55

要回复问题请先登录注册