Skip to content

Add panel. prefix to permissions and new editor role - #730

Merged
giuscris merged 10 commits into
2.xfrom
user-roles-permission-updates
Jul 12, 2025
Merged

Add panel. prefix to permissions and new editor role#730
giuscris merged 10 commits into
2.xfrom
user-roles-permission-updates

Conversation

@giuscris

Copy link
Copy Markdown
Member

The intention of this pull request is to improve the user management for Formwork 2.0, and allow in future frontend users (maybe with a plugin).

The major and breaking change is that now all existing permissions, all within the panel, are now prefixed with panel., so they won't collide with future site.* permissions.

It also adds a new editor role to replace the previous user role (now reserved for future usage, e.g. frontend users).

Another important change is that now administrators cannot change passwords of other users. Every user, independently from their role chan change only their own password.

@giuscris giuscris added this to the 2.0.0 milestone Jul 12, 2025
@giuscris
giuscris requested a review from Copilot July 12, 2025 16:22
@giuscris giuscris self-assigned this Jul 12, 2025
@giuscris giuscris added the enhancement New feature or request label Jul 12, 2025

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR scopes all existing backend permissions under a panel. prefix and introduces a new editor role, while preventing administrators from changing other users’ passwords.

  • Prefix all permission keys in views, controllers, and navigation with panel.
  • Add an editor role configuration supporting the main panel modules
  • Simplify the Permissions loader and fallback logic in code, and update user/password field behavior

Reviewed Changes

Copilot reviewed 41 out of 41 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
site/users/roles/user.yaml Removed legacy user permissions block
site/users/roles/editor.yaml Added new editor role with scoped panel.* permissions
site/users/roles/admin.yaml Replaced detailed admin permissions with a single panel: true entry
site/schemes/users/user.yaml Unlocked password and role fields for runtime visibility control
panel/views/... Updated all has() checks to use the panel. prefix
panel/config/navigation.php Prefixed navigation item permissions and changed logout to null
formwork/src/Users/Permissions.php Simplified constructor and updated permission inheritance via beforeLast
formwork/src/Panel/Controllers/... Prefixed all controller guards to use panel.* keys
formwork/translations/*.yaml Added user.role.editor labels; updated FR locale
Comments suppressed due to low confidence (2)

site/users/roles/user.yaml:1

  • The user.yaml file no longer defines any permissions after removing the block. Regular users will be unable to access any panel actions. Please restore the permissions mapping with appropriate panel.* prefixes.
title: '{{user.role.user}}'

formwork/src/Users/Permissions.php:17

  • Wildcard (*) permission handling was removed and no longer short-circuits in has(), which can lead to infinite recursion if has('*') is called. Consider reintroducing an explicit check for '*' before fallback logic.
    public function has(string $permission): bool

Comment thread formwork/translations/fr.yaml Outdated
giuscris and others added 2 commits July 12, 2025 18:26
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@giuscris
giuscris merged commit f3acf42 into 2.x Jul 12, 2025
1 check passed
@giuscris
giuscris deleted the user-roles-permission-updates branch July 12, 2025 21:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants