settings

package
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 8, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package settings holds the Githome web front's account settings handlers. The account settings tree lives under /settings and is gated to the signed-in viewer: it administers the viewer's own account, so an anonymous request gets the same 404 as any page that is not there, never a sign-in wall that confirms the surface exists. Githome backs one account section today, the appearance preference, since the color mode and themes ride cookies the color-mode middleware already reads; the unbacked sections (profile, emails, keys, tokens, sessions, security) get no nav entry rather than a dead link, the same honest absence the profile took for its unbacked tabs. Every mutation posts and redirects, so the no-JS flow lands on a clean GET, and the CSRF guard the page chain installs verifies each post. See implementation/13.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Deps

type Deps struct {
	Render *render.Set
	View   *view.Builder
	Flash  Flasher
	Logger *slog.Logger
}

Deps are the account settings handlers' dependencies: the render set, the view builder for the shell chrome, the flash store for the one-shot outcome notice a save reports after its redirect, and a logger.

type Flasher

type Flasher interface {
	Add(c *mizu.Ctx, kind, message string)
}

Flasher is the slice of the flash store the settings handlers use: stage a one-shot message to show on the page the redirect lands on. The webmw.Flash satisfies it; the narrow interface keeps the handler testable without a cookie round-trip.

type Handlers

type Handlers struct {
	// contains filtered or unexported fields
}

Handlers is the account settings handler set. One is built at boot and shared; it holds no per-request state.

func New

func New(d Deps) *Handlers

New wires the handler set from its dependencies.

func (*Handlers) Appearance

func (h *Handlers) Appearance(c *mizu.Ctx) error

Appearance renders the appearance form, prefilled from the color mode the middleware resolved for this request, so the form opens showing the viewer's current choice rather than a default.

func (*Handlers) Index

func (h *Handlers) Index(c *mizu.Ctx) error

Index redirects the bare /settings root to the first backed section. A bookmark of /settings keeps working as Githome adds sections, always landing on a real page rather than a blank index.

func (*Handlers) SaveAppearance

func (h *Handlers) SaveAppearance(c *mizu.Ctx) error

SaveAppearance validates the submitted mode and themes against the closed catalogs the form offered, writes the three cookies, and redirects back to the form with a flash. The form can only present valid values, so a value outside the catalogs is a forged post: it is rejected with an error flash and no cookie is written, rather than poisoning the preference with a theme that does not exist.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL