sylvainjule/bouncer

限制用户角色对面板中特定页面(及其子页面)的访问。

安装次数: 2,248

依赖: 0

建议者: 0

安全性: 0

星标: 60

关注者: 2

分支: 6

开放问题: 4

类型:kirby-plugin

1.1.0 2024-03-07 10:05 UTC

This package is auto-updated.

Last update: 2024-09-07 11:34:53 UTC


README

限制用户角色对面板中特定页面(及其子页面)的访问。

bouncer-screenshot


概述

此插件完全免费,并使用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