- 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
24 lines
674 B
Go
24 lines
674 B
Go
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()
|
|
}
|