feat(19.6.1-01): Administrators screen and cross-controller record actions
- pact.HasAdminActionExtensions / AdminActionExtension: plugins add record actions to any admin controller by ID, merged at boot before permission validation (unknown target, no preview, duplicate name stop the boot) - internal summercms.cabana pseudo-plugin, appended only when some plugin registers admin controllers: Administrators list and preview, settings link under System, backend.manage_users and backend.manage_roles with no role grants - backend::lang user, user.role and permissions copy (en, pl) - smoke tests: compile-time seam and settings, Postgres list/preview/action
This commit is contained in:
@@ -27,6 +27,21 @@ type BackendUserRole struct {
|
||||
|
||||
func (BackendUserRole) TableName() string { return "backend_user_roles" }
|
||||
|
||||
// Fillable lists the role columns the admin's Roles screen writes from a
|
||||
// form: name, code and description. permissions and is_system are never
|
||||
// filled (the permission editor stores the grants, and is_system only comes
|
||||
// from migrations).
|
||||
func (BackendUserRole) Fillable() []string { return []string{"name", "code", "description"} }
|
||||
|
||||
// Rules are the role's admin save rules: a name unique among roles and a
|
||||
// code. The code's uniqueness is checked by the Roles screen itself.
|
||||
func (BackendUserRole) Rules() map[string]string {
|
||||
return map[string]string{
|
||||
"name": "required|max:255|unique:backend_user_roles",
|
||||
"code": "required|max:255",
|
||||
}
|
||||
}
|
||||
|
||||
// BackendUser is the Winter backend_users row. It is not a frontend user.
|
||||
// Nullable Winter columns are mapped so a copied row round-trips without a
|
||||
// schema transform. TokensValidAfter is the admin reset cutoff, not a Winter column.
|
||||
@@ -59,6 +74,24 @@ type BackendUser struct {
|
||||
|
||||
func (BackendUser) TableName() string { return "backend_users" }
|
||||
|
||||
// Fillable lists the columns the admin's Administrators screen writes from a
|
||||
// form: login, email, first and last name. Role, permissions, the superuser
|
||||
// flag, activation and the password are protected and written only by the
|
||||
// screen's own checks.
|
||||
func (BackendUser) Fillable() []string {
|
||||
return []string{"login", "email", "first_name", "last_name"}
|
||||
}
|
||||
|
||||
// Rules are the administrator's admin save rules. The uniqueness of login
|
||||
// and email, deleted administrators included and ignoring case, is checked
|
||||
// by the Administrators screen itself.
|
||||
func (BackendUser) Rules() map[string]string {
|
||||
return map[string]string{
|
||||
"login": "required|max:255",
|
||||
"email": "required|email|max:255",
|
||||
}
|
||||
}
|
||||
|
||||
const (
|
||||
// BackendUserMorphType is the system_files attachment_type of a backend
|
||||
// user's files: WinterCMS's class string, so avatar rows copied from
|
||||
@@ -114,6 +147,9 @@ type CompiledController struct {
|
||||
// RecordActions are the controller's pact.HasAdminRecordActions entries
|
||||
// keyed by name, a third namespace with the same reserved names.
|
||||
RecordActions map[string]pact.AdminRecordAction
|
||||
// contributed maps the name of each record action another plugin added
|
||||
// through pact.HasAdminActionExtensions to that plugin's ID.
|
||||
contributed map[string]string
|
||||
|
||||
// scripts and styles are the controller's declared plugin JS and CSS,
|
||||
// in declared order.
|
||||
@@ -147,9 +183,12 @@ type CompiledController struct {
|
||||
type Registry struct {
|
||||
byID map[string]*CompiledController
|
||||
permissions map[string]pact.Permission
|
||||
roleGrants map[string]map[string]bool
|
||||
navigation []pact.NavigationItem
|
||||
settings map[string]*CompiledSetting
|
||||
// permissionOrder holds the permission codes in registration order
|
||||
// (plugin activation order, then each plugin's declared order).
|
||||
permissionOrder []string
|
||||
roleGrants map[string]map[string]bool
|
||||
navigation []pact.NavigationItem
|
||||
settings map[string]*CompiledSetting
|
||||
// assets are every controller's declared plugin files keyed by URL tail
|
||||
// (vendor/plugin/<path after assets/>); the asset route serves only these.
|
||||
assets map[string]*pluginAsset
|
||||
|
||||
Reference in New Issue
Block a user