【问题标题】:sails-permissions grant not working with criteria帆许可授予不符合标准
【发布时间】:2015-11-28 21:14:18
【问题描述】:

我已经设置了sails 权限并且它运行良好。我似乎只是在尝试授予角色读取某个条件的权限时遇到问题。

我想要实现的确切目标如下: - 角色 Public 中的用户应该能够读取/查看菜单模型中属性“状态”设置为“已批准”的任何菜单。

PermissionService.grant({action: 'read', model: 'Menu', role: 'public', criteria: [ { where:{ status: 'approved'}}]})

我认为我的语法有问题,但它似乎接受了它。运行命令后,我收到 500 错误消息...重新启动后,它显示 404。

有没有人见过这个,或者可以验证我的语法?

【问题讨论】:

    标签: mongodb sails.js sails-permissions


    【解决方案1】:

    尝试在您的语句后添加 .then(console.log).catch(console.log) 使其变为:

    PermissionService.grant({action: 'read', model: 'Menu', role: 'public', criteria: [ { where:{ status: 'approved'}}]}).then(console.log).catch(console.log);
    

    这将向您显示有关错误的更多信息并帮助您进行调试。也在这里发布错误!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-10-31
      • 2018-01-07
      • 2018-08-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-06-02
      相关资源
      最近更新 更多