NextMyDay/internal/core/setup
Claus Lohmar 7c1826e115 fix(setup): render the TOTP step instead of the enroll flow's JSON
The first-run wizard's `admin.totp.begin` delegated to the enroll flow's
`TOTPBegin`, which is `webauthn.js`'s JSON API: the browser was shown raw
`{"otpauth_url":…}` and the wizard stalled at step 2, rendering no secret.

Extract the issue step into a write-free seam, `flow.Actions.IssueTOTP`, and
keep `TOTPBegin`'s JSON contract by having it call the seam. The wizard now
issues via the seam and renders its own HTML page (`text/html`, inside the
shell, no inline scripts) showing the otpauth URL, the human-readable secret
for manual entry, and the verify form (pre-session CSRF, A15).

`setup.Enroller` drops `TOTPBegin` — the wizard no longer calls it, and a
JSON-writing method on a no-JS seam is the coupling that caused the bug.

Tighten the tests that missed it: `setup_wizard_test.go` asserts the `begin`
response is `text/html` and carries the secret and the verify form (not merely
200), keeping the end-to-end begin→code→303 path; `enroll_login_test.go` pins
the enroll flow's JSON contract (`application/json` + `otpauth_url`).

Spec: docs/specs/spec-005-setup-wizard.md §11.
2026-10-15 07:07:31 +00:00
..
gate.go feat(setup): gate setup with the config toggle and an optional code 2026-10-15 06:47:33 +00:00
render.go fix(setup): render the TOTP step instead of the enroll flow's JSON 2026-10-15 07:07:31 +00:00
setup.go fix(setup): render the TOTP step instead of the enroll flow's JSON 2026-10-15 07:07:31 +00:00