已有角色新增用户问题 云引擎

没有保错 undefine

开下调试日志,会有详细日志(包括发送的网络请求)。另外注意角色添加成员后,要保存(save)才生效。

const admin = new AV.Role('qeeq');

admin.getUsers().add(req.currentUser);

const dd = await admin.save()

console.log(dd)

Unhandled Rejection at: Promise Promise {
Error: Role ACL is required. [400 POST https://i7ldexfb.api.lncld.net/1.1/classes/_Role]
at D:\lcapp\lingtianshop\node_modules\leancloud-storage\dist\node\request.js:163:17
at tryCatch (D:\lcapp\lingtianshop\node_modules\es6-promise\dist\es6-promise.js:410:12)
at invokeCallback (D:\lcapp\lingtianshop\node_modules\es6-promise\dist\es6-promise.js:425:13)
at publish (D:\lcapp\lingtianshop\node_modules\es6-promise\dist\es6-promise.js:399:7)
at publishRejection (D:\lcapp\lingtianshop\node_modules\es6-promise\dist\es6-promise.js:340:3)
at flush (D:\lcapp\lingtianshop\node_modules\es6-promise\dist\es6-promise.js:128:5)
at processTicksAndRejections (internal/process/task_queues.js:79:11) {
code: 1,
rawMessage: 'Role ACL is required.'
}

const roleQuery = new AV.Query('_Role');
roleQuery.equalTo('name', 'test');
用传统的方式 可以对已有角色增加用户

Role ACL is required

这个报错说明您没有为 admin 这个角色本身设置 ACL,您需要在创建 admin 时设置下 ACL。