sylvainjule / bouncer
限制用户角色对面板中特定页面(及其子页面)的访问。
1.1.0
2024-03-07 10:05 UTC
Requires
README
限制用户角色对面板中特定页面(及其子页面)的访问。
概述
此插件完全免费,并使用MIT许可证发布。然而,如果您在商业项目中使用它并希望帮助我进行维护,请考虑进行捐赠或通过我的联盟链接购买您的许可证。
1. 安装
下载并复制此存储库到 /site/plugins/bouncer
或者,您可以使用composer安装它:composer require sylvainjule/bouncer
2. 设置
此插件旨在限制用户的编辑能力,仅限于他们的“账户”页面 + 在“页面”字段中选择的页面(及其子页面)。
- 首先,创建一个新的用户角色(例如,
/site/blueprints/users/test.yml
) - 设置其权限,并添加一个
pages
字段
title: Test permissions: access: panel: true site: true settings: false languages: false users: false # ... user: changeRole: false delete: false update: false # else a user will be able to edit the page they have access to on their profile fields: canaccess: label: 'The user will only be able to access:' type: pages multiple: false options: query query: site.pages # or any query that suits your needs
- 在您的
site/config/config.php
中,告诉插件要使用的role => fieldname
关联
return [ 'sylvainjule.bouncer.list' => [ 'test' => [ // match the filename without extension of the user blueprint 'fieldname' => 'canaccess' ] ] ];
2.1 可选页面切换器
(测试版)
从1.0.1版本开始,特定用户可以访问不同的页面。您可以从蓝图移除multiple: false
选项
# User role blueprint title: Test fields: canaccess: label: 'The user will only be able to access:' type: pages options: query query: site.pages # or any query that suits your needs
在您希望显示页面切换器的每个页面上添加一个bouncernav
部分
// Anywhere in any blueprint (...) sections: bouncernav: type: bouncernav
然后在您的 config.php
中声明您想为特定用户角色显示页面切换器
return [ 'sylvainjule.bouncer.list' => [ 'test' => [ 'fieldname' => 'canaccess', 'nav' => true ] ] ];
3. 免责声明
我需要这个功能来创建一个网站,并将其转换为一个插件。我希望它能有所帮助,但无意使用此插件扩展它或支持更精细的限制场景。
4. 许可证
MIT