【问题标题】:How can I restrict view access to a page type in SilverStripe to admin users only?如何将 SilverStripe 中页面类型的查看权限限制为仅限管理员用户?
【发布时间】:2015-01-27 04:08:39
【问题描述】:

如何将 SilverStripe 中某个页面类型的查看权限限制为仅限管理员用户?

我更喜欢通过代码本身来完成,但通过 CMS 也很高兴。

我认为this answer 让我大部分时间到达那里;也许我只需要找到管理员组?

【问题讨论】:

    标签: silverstripe access-control


    【解决方案1】:

    是的,您链接到的答案就是您需要做的。要获取组的 ID,您可以执行类似 Group::get()->filter('Code', 'administrators')->first()->ID; 的操作。

    另一种选择是检查权限,例如

    public function canView($member = null) {
        return Permission::checkMember($member, "ADMIN") !== false;
    }
    

    Willr mentions here 检查权限可能会更好。

    您可能会发现这些 API 很有用:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-04-12
      • 1970-01-01
      • 2014-09-28
      • 2015-11-01
      • 2010-11-01
      • 1970-01-01
      • 2012-06-26
      • 2018-06-03
      相关资源
      最近更新 更多