【问题标题】:Orchard Permissions in a custom module自定义模块中的果园权限
【发布时间】:2012-03-01 10:47:11
【问题描述】:

所以我创建了我的第一个 Orchard 模块,它本质上只是管理面板中的一个 CRUD,并带有一个可供公众使用的前端表单。现在我需要在管理面板中为不同的用户角色提供不同级别的访问权限。我已经很好地创建了“管理员”用户,但现在我遇到了权限较低的用户的问题,他们只能看到记录的子集。

问题是我不知道从哪里开始。我很乐意在我的列表屏幕上说:if (UserRole == "SomeRestrictedRole") Select.Where("however we restrict"); - 但我不知道如何访问 UserRole(我也是 .NET MVC 的新手)。

我认为正确的解决方案是扩展 IPermissions 或类似的东西?但同样,我找不到任何教程或文档来为我指明正确的方向。

这是我目前阅读的文档:

http://docs.orchardproject.net/Documentation/Creating-a-module-with-a-simple-text-editor

http://docs.orchardproject.net/Documentation/Understanding-data-access

http://docs.orchardproject.net/Documentation/Managing-users-and-roles

http://docs.orchardproject.net/Documentation/Understanding-permissions

任何建议将不胜感激!

【问题讨论】:

    标签: c# asp.net permissions orchardcms


    【解决方案1】:

    对,不要根据角色来限制访问,而是根据权限来限制访问。查看任何 Permissions.cs 以获取实施示例。然后搜索其中声明的权限以查看执行它们的示例。这真的很容易,你会看到:)

    【讨论】:

    • 谢谢,我使用的是 Orchard 的二进制版本。加载源代码,你是对的,很明显复制现有的 Permissions.cs 然后使用 Authorizer.Authorize
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-04-14
    • 1970-01-01
    • 2013-01-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多