Node.js 环回ACL“;需要授权”;使用mySql连接器

Node.js 环回ACL“;需要授权”;使用mySql连接器,node.js,loopbackjs,Node.js,Loopbackjs,我希望具有特定角色的用户能够将数据写入端点,并且由于某种原因,我设置的用户(处于这些角色之一)无法写入数据。我得到以下错误:下面是我的代码 module.exports = function (app) { let today = new Date(); let admin = { name: 'admin', description: 'admin users', created: today.toJSON(),

我希望具有特定角色的用户能够将数据写入端点,并且由于某种原因,我设置的用户(处于这些角色之一)无法写入数据。我得到以下错误:下面是我的代码

module.exports = function (app) {
    let today = new Date();

    let admin = {
        name: 'admin',
        description: 'admin users',
        created: today.toJSON(),
        modified: today.toJSON()
    };

    let internal = {
        name: 'internal',
        description: 'Internal users',
        created: today.toJSON(),
        modified: today.toJSON()
    };

    let external = {
        name: 'external',
        description: 'external users',
        created: today.toJSON(),
        modified: today.toJSON()
    };

    let bot = {
        name: 'bot',
        description: 'robots',
        created: today.toJSON(),
        modified: today.toJSON()
    };

    let model = app.models.user;

    model.create([
        {username: 'bot', email: 'example@example.com', password: 'test123'},
        {username: 'admin', email: 'example2@example.com', password: 'test123'},
        {username: 'iAdmin', email: 'example3@example.com', password: 'test123'},
        {username: 'eUser', email: 'example4@example.com', password: 'test123'},
    ], function(err, users) {

        if (err) throw err;

           app.models.Role.create(bot, function (err, botRole) {

            if (err) throw err


                botRole.principals.create({principalType: app.models.RoleMapping.USER, principalID: users[0].id}, function(err, principal) {
                if (err) throw err;
            });


        });

        app.models.Role.create(admin, function (err, adminRole) {
            if (err) throw err;

            adminRole.principals.create({principalType: app.models.RoleMapping.USER, PrincipalID: users[1].id}, function(err, principal) {
                if (err) throw err;
            });
        });

       app.models.Role.create(admin, function (err, internalRole) {
            if (err) throw err;

            internalRole.principals.create({principalType: app.models.RoleMapping.USER, PrincipalID: users[2].id}, function(err, principal) {
                if (err) throw err;
            });
        });

        app.models.Role.create(external, function (err, externalRole) {
            if (err) throw err;

            externalRole.principals.create({principalType: app.models.RoleMapping.USER, PrincipalID: users[3].id}, function(err, principal) {
                if (err) throw err;
            });
        });
    });
};
模型配置:

"User": {
    "dataSource": "mySqldb",
    "public": false
  },
  "user": {
    "dataSource": "mySqldb",
    "public": true
  },
  "AccessToken": {
    "dataSource": "mySqldb",
    "public": false
  },
  "ACL": {
    "dataSource": "mySqldb",
    "public": false
  },
  "RoleMapping": {
    "dataSource": "mySqldb",
    "public": false,
    "options": {
      "strictObjectIDCoercion": true
    }
  },
  "Role": {
    "dataSource": "mySqldb",
    "public": false
  }
ACL:

错误:
ValidationError:
用户
实例无效。详细信息:
secret\u key
不能为空(值:未定义)<使用登录的代码不能为空(值:未定义)<代码>用户名无效(值:“bot”)<代码>电子邮件无效(值:example@example.com“

您得到的错误是什么???@Subburaj在after save操作挂钩中,我想编写逻辑,以便我从ctx(即ctx.instance.email)接收到的数据,即我必须插入到用户模型中,我如何做到这一点?
"acls": [
    {
        "accessType": "*",
        "principalType": "ROLE",
        "principalId": "$everyone",
        "permission": "DENY"
    },
    {
        "accessType": "READ",
        "principalType": "ROLE",
        "principalId": "$authenticated",
        "permission": "ALLOW"
    },
    {
        "accessType": "WRITE",
        "principalType": "ROLE",
        "principalId": "admin",
        "permission": "ALLOW"
    },
     {
        "accessType": "DELETE",
        "principalType": "ROLE",
        "principalId": "admin",
        "permission": "ALLOW"
    }
  ],