Documentation
¶
Index ¶
- Constants
- func EnsureDashboardFirst(ctx context.Context, menuSvc admin.CMSMenuService, ...) error
- func NewDashboardRenderer() (admin.DashboardRenderer, error)
- func NewGoUsersActivityAdapter(sink types.ActivitySink, repo types.ActivityRepository) admin.ActivitySink
- func NewMediaPanelBuilder(store *stores.MediaStore) *admin.PanelBuilder
- func NewPagesPanelBuilder(store stores.PageRepository) *admin.PanelBuilder
- func NewPostsPanelBuilder(store stores.PostRepository) *admin.PanelBuilder
- func NewSecureLinkManager() (userstypes.SecureLinkManager, error)
- func NewUserPanelBuilder(store *stores.UserStore) *admin.PanelBuilder
- func PasswordPolicyHints() []string
- func ResolveUsersDSN() string
- func SeedAdminNavigation(ctx context.Context, menuSvc admin.CMSMenuService, cfg admin.Config, ...) error
- func SeedUsers(ctx context.Context, deps stores.UserDependencies, ...) error
- func SetupActivityWithGoUsers() admin.ActivitySink
- func SetupAuth(adm *admin.Admin, dataStores *stores.DataStores, deps stores.UserDependencies, ...) (*admin.GoAuthAuthenticator, *auth.RouteAuthenticator, *auth.Auther, string)
- func SetupDashboard(adm *admin.Admin, dataStores *stores.DataStores, basePath string)
- func SetupNavigation(ctx context.Context, menuSvc admin.CMSMenuService, ...) error
- func SetupPersistentCMS(ctx context.Context, defaultLocale, dsn string) (admin.CMSOptions, error)
- func SetupSettings(adm *admin.Admin)
- func SetupSettingsWithOptions(adm *admin.Admin)
- type AuthOption
- type GoUsersPreferencesStore
- func (s *GoUsersPreferencesStore) Delete(ctx context.Context, input admin.PreferencesDeleteInput) error
- func (s *GoUsersPreferencesStore) Resolve(ctx context.Context, input admin.PreferencesResolveInput) (admin.PreferenceSnapshot, error)
- func (s *GoUsersPreferencesStore) Upsert(ctx context.Context, input admin.PreferencesUpsertInput) (admin.PreferenceSnapshot, error)
- type OnboardingNotifier
- func SetupUsers(ctx context.Context, dsn string, opts ...persistence.ClientOption) (stores.UserDependencies, *userssvc.Service, *OnboardingNotifier, error)
- func SetupUsersWithMigrations(ctx context.Context, dsn string, registrar UserMigrationsRegistrar, ...) (stores.UserDependencies, *userssvc.Service, *OnboardingNotifier, error)
- type RegistrationConfig
- type RegistrationMode
- type SecureLinkUIConfig
- type UserMigrationsPhase
- type UserMigrationsRegistrar
Constants ¶
const ( NavigationMenuCode = "admin_main" SiteNavigationMenuCode = "site_main" NavigationGroupMain = NavigationMenuCode + ".nav-group-main" NavigationGroupOthers = NavigationMenuCode + ".nav-group-others" NavigationSectionContent = NavigationGroupMain + ".content" NavigationSectionDashboard = NavigationGroupMain + ".dashboard" NavigationSectionShop = NavigationGroupMain + ".shop" )
const ( FeatureUserInvites = "users.invite" FeaturePasswordReset = "users.password_reset" FeatureSelfRegistration = "users.signup" )
Variables ¶
This section is empty.
Functions ¶
func EnsureDashboardFirst ¶
func EnsureDashboardFirst(ctx context.Context, menuSvc admin.CMSMenuService, basePath, menuCode, locale string) error
EnsureDashboardFirst updates persisted menu item positions so Dashboard renders before Content. This is useful for persistent CMS backends where module menu items are only inserted once.
func NewDashboardRenderer ¶
func NewDashboardRenderer() (admin.DashboardRenderer, error)
NewDashboardRenderer creates a template-based dashboard renderer
func NewGoUsersActivityAdapter ¶
func NewGoUsersActivityAdapter(sink types.ActivitySink, repo types.ActivityRepository) admin.ActivitySink
NewGoUsersActivityAdapter bridges go-users activity sink/repo into admin.
func NewMediaPanelBuilder ¶
func NewMediaPanelBuilder(store *stores.MediaStore) *admin.PanelBuilder
NewMediaPanelBuilder creates a panel builder for media
func NewPagesPanelBuilder ¶
func NewPagesPanelBuilder(store stores.PageRepository) *admin.PanelBuilder
NewPagesPanelBuilder creates a panel builder for pages
func NewPostsPanelBuilder ¶
func NewPostsPanelBuilder(store stores.PostRepository) *admin.PanelBuilder
NewPostsPanelBuilder creates a panel builder for posts
func NewSecureLinkManager ¶ added in v0.19.0
func NewSecureLinkManager() (userstypes.SecureLinkManager, error)
NewSecureLinkManager builds a securelink manager for onboarding flows.
func NewUserPanelBuilder ¶
func NewUserPanelBuilder(store *stores.UserStore) *admin.PanelBuilder
NewUserPanelBuilder creates a panel builder for users
func PasswordPolicyHints ¶ added in v0.19.0
func PasswordPolicyHints() []string
PasswordPolicyHints returns UI hints for password requirements.
func ResolveUsersDSN ¶
func ResolveUsersDSN() string
ResolveUsersDSN returns the SQLite DSN shared with the rest of the example (CMS).
func SeedAdminNavigation ¶
func SeedAdminNavigation(ctx context.Context, menuSvc admin.CMSMenuService, cfg admin.Config, modules []admin.Module, gates featureGates, isDev bool) error
SeedAdminNavigation converges the example admin navigation menu so parent scaffolding, ordering, and module-contributed items remain deterministic across restarts.
When the CMS menu service is backed by go-cms, this uses cms.SeedMenu with Ensure enabled (and PruneUnspecified in development) so sibling ordering is repaired without ad-hoc resets.
func SeedUsers ¶
func SeedUsers(ctx context.Context, deps stores.UserDependencies, preferenceRepo *preferences.Repository) error
SeedUsers inserts the demo users into SQLite and seeds preferences.
func SetupActivityWithGoUsers ¶
func SetupActivityWithGoUsers() admin.ActivitySink
SetupActivityWithGoUsers provisions a go-users-compatible activity sink. It returns an admin.ActivitySink that logs to a go-users ActivitySink/Repository while retaining the admin UI fallback buffer via ActivitySinkAdapter.
func SetupAuth ¶
func SetupAuth(adm *admin.Admin, dataStores *stores.DataStores, deps stores.UserDependencies, opts ...AuthOption) (*admin.GoAuthAuthenticator, *auth.RouteAuthenticator, *auth.Auther, string)
SetupAuth wires go-auth middleware and authorizer with the admin orchestrator. It returns the admin authenticator adapter, the underlying RouteAuthenticator, the Auther, and the context key used for the auth cookie.
func SetupDashboard ¶
func SetupDashboard(adm *admin.Admin, dataStores *stores.DataStores, basePath string)
SetupDashboard configures dashboard widgets for the admin panel
func SetupNavigation ¶
func SetupNavigation(ctx context.Context, menuSvc admin.CMSMenuService, basePath, menuCode, locale string) error
SetupNavigation seeds the CMS menu service with grouped, translatable navigation.
func SetupPersistentCMS ¶
SetupPersistentCMS wires a go-cms container backed by Bun/SQLite and applies migrations. DSN falls back to a temp file (under /tmp) when none is provided and can be overridden via CONTENT_DATABASE_DSN (preferred) or CMS_DATABASE_DSN to keep env parity with the existing example.
func SetupSettings ¶
SetupSettings configures settings definitions for the admin panel.
func SetupSettingsWithOptions ¶
SetupSettingsWithOptions swaps the settings backend to the go-options adapter.
Types ¶
type AuthOption ¶ added in v0.11.0
type AuthOption func(*authOptions)
AuthOption configures optional demo auth behavior.
func WithDefaultScope ¶ added in v0.11.0
func WithDefaultScope(tenantID, orgID string) AuthOption
WithDefaultScope injects tenant/org metadata into demo JWTs when available.
type GoUsersPreferencesStore ¶
type GoUsersPreferencesStore struct {
// contains filtered or unexported fields
}
GoUsersPreferencesStore bridges go-users preferences into the admin preferences contract.
func NewGoUsersPreferencesStore ¶
func NewGoUsersPreferencesStore(repo types.PreferenceRepository) (*GoUsersPreferencesStore, error)
NewGoUsersPreferencesStore builds a preferences store backed by go-users.
func (*GoUsersPreferencesStore) Delete ¶ added in v0.11.0
func (s *GoUsersPreferencesStore) Delete(ctx context.Context, input admin.PreferencesDeleteInput) error
func (*GoUsersPreferencesStore) Resolve ¶ added in v0.11.0
func (s *GoUsersPreferencesStore) Resolve(ctx context.Context, input admin.PreferencesResolveInput) (admin.PreferenceSnapshot, error)
func (*GoUsersPreferencesStore) Upsert ¶ added in v0.11.0
func (s *GoUsersPreferencesStore) Upsert(ctx context.Context, input admin.PreferencesUpsertInput) (admin.PreferenceSnapshot, error)
type OnboardingNotifier ¶
type OnboardingNotifier struct {
Notifications admin.NotificationService
Activity types.ActivitySink
}
OnboardingNotifier fans out invite/reset activity into notifications.
func SetupUsers ¶
func SetupUsers(ctx context.Context, dsn string, opts ...persistence.ClientOption) (stores.UserDependencies, *userssvc.Service, *OnboardingNotifier, error)
SetupUsers wires a go-users stack against the shared SQLite DB (runs migrations).
func SetupUsersWithMigrations ¶ added in v0.19.0
func SetupUsersWithMigrations(ctx context.Context, dsn string, registrar UserMigrationsRegistrar, opts ...persistence.ClientOption) (stores.UserDependencies, *userssvc.Service, *OnboardingNotifier, error)
SetupUsersWithMigrations wires a go-users stack with a custom migrations registrar.
func (*OnboardingNotifier) HandleActivity ¶
func (n *OnboardingNotifier) HandleActivity(ctx context.Context, record types.ActivityRecord)
HandleActivity attaches to go-users hooks to emit example notifications.
type RegistrationConfig ¶
type RegistrationConfig struct {
Mode RegistrationMode
Allowlist []string
}
RegistrationConfig controls self-registration guardrails.
func DefaultRegistrationConfig ¶
func DefaultRegistrationConfig() RegistrationConfig
DefaultRegistrationConfig returns a closed registration mode with a sample allowlist.
func (RegistrationConfig) AllowsEmail ¶
func (c RegistrationConfig) AllowsEmail(email string) bool
AllowsEmail reports whether the email is permitted under the current allowlist.
type RegistrationMode ¶
type RegistrationMode string
RegistrationMode governs whether self-registration is open, restricted, or disabled.
const ( RegistrationClosed RegistrationMode = "closed" RegistrationAllowlist RegistrationMode = "allowlist" RegistrationOpen RegistrationMode = "open" )
type SecureLinkUIConfig ¶ added in v0.19.0
SecureLinkUIConfig exposes link parsing details for UI templates.
func SecureLinkUIConfigFromEnv ¶ added in v0.19.0
func SecureLinkUIConfigFromEnv() SecureLinkUIConfig
SecureLinkUIConfigFromEnv returns securelink parsing defaults for templates.
type UserMigrationsPhase ¶ added in v0.19.0
type UserMigrationsPhase int
UserMigrationsPhase identifies which migrations should be registered.
const ( UserMigrationsAuth UserMigrationsPhase = iota UserMigrationsCore )
type UserMigrationsRegistrar ¶ added in v0.19.0
type UserMigrationsRegistrar func(*persistence.Client, UserMigrationsPhase) error
UserMigrationsRegistrar registers migrations for the given phase.
func QuickstartUserMigrations ¶ added in v0.19.0
func QuickstartUserMigrations() UserMigrationsRegistrar
QuickstartUserMigrations returns a registrar that uses quickstart defaults.