feat: register the Users admin screen with the privileged-member guard
- permissions (the four Winter codes and manage_privileged_groups), the user navigation item and the embedded admin YAML - Users controller: list with deactivated users, row states, the groups, created date and activated filters, and the form's name, surname and email - a member of a group in golem15.user.privileged_groups (default admin) keeps their email, password and row unless the administrator holds golem15.users.manage_privileged_groups; the refusal is a 403 that saves nothing
This commit is contained in:
23
controllers/request_db.go
Normal file
23
controllers/request_db.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"git.golem15.com/golem15/summercms/modules/cabana"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// requestDB is the database handle a hook or scope should read through. Inside
|
||||
// an admin write it is the transaction the write runs in, so the hook sees the
|
||||
// write's snapshot and does not take a second pool connection while the
|
||||
// transaction holds row locks. Outside a transaction (the list) it is the
|
||||
// application pool from the booted app. It is nil when neither exists.
|
||||
func requestDB(ctx context.Context, pool func() *gorm.DB) *gorm.DB {
|
||||
if tx, ok := cabana.TxFromContext(ctx); ok {
|
||||
return tx
|
||||
}
|
||||
if pool == nil {
|
||||
return nil
|
||||
}
|
||||
return pool()
|
||||
}
|
||||
Reference in New Issue
Block a user