fix(web): never trap an admin on the onboarding email-verification gate (BUNYIP-401) #393
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/BUNYIP-401-admin-never-trapped-on-unverified-email"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes BUNYIP-401. The chicken-and-egg behind PSA-1's "Verify the onboarding process for the admin".
Problem
bunyip-web/src/handlers/mod.rs::needs_onboardingpinned a named-but-unverified user to/onboardingwheneversetup_status.email_enabled == true. The onboarding allowlist excludes the admin surface, andadmin_guardrunsguard(path = "/admin"), so a gated admin could not reach/admin/emailto configure SMTP. When delivery is enabled but not actually working (bad credentials, DMARC/SPF reject, wrongSMTP_FROM, unreachable relay) the verification mail never arrives and the only admin is permanently locked out.login/registercarry no verification gate (the BUNYIP-290 bootstrap-admin promotion already works); the trap was solely the web onboarding gate. Bunyip already exemptedemail_enabled == false; the missing case isemail_enabled == truebut undeliverable, where the admin is the one party who must be able to intervene.Fix
Exempt the admin role from the email-verification arm of the onboarding gate. A name is still required (self-service, no email needed); the dashboard keeps the "unverified" badge + resend control, so an admin can still verify once mail works. Regular (non-admin) users are unchanged. The decision is split into a pure
onboarding_needed(names_present, email_verified, is_admin, email_enabled)helper so the full matrix is unit-testable without anAppState.Acceptance
/onboardingand can reach/admin/email, even whenemail_enabled = true.onboarding_gate_matrix,admin_is_never_trapped_on_unverified_email).Verification
cargo test -p bunyip-web onboarding_gate: 5 passed.cargo fmt --all --checkclean,cargo clippy -p bunyip-webclean.Rollout note
This fix ships in the next bunyip release. Until it is deployed, the immediate operational unblock is to boot bunyip with
EMAIL_ENABLED=false(or via the admin escape hatch), let the bootstrap admin in, configure SMTP in/admin/email, then re-enable email.Operational unblock
Uses bunyip's built-in escape hatch: with email_enabled == false, the onboarding gate stops requiring verification, so the admin reaches /admin/email.
Pick the locked-out host - staging = ~/docker/server/c-01/bunyip-api, prod = ~/docker/server/nc-01/bunyip-api.
nushell
on the docker repo (edit the pin), example = staging c-01
cd ~/docker
git switch main; git pull --ff-only
git switch --create chore/bunyip-email-disabled-bootstrap
in server/c-01/bunyip-api/compose-variables.yml set: EMAIL_ENABLED: "false"
git commit --all --message "chore(bunyip): temporarily disable email for admin bootstrap"
git push --set-upstream origin chore/bunyip-email-disabled-bootstrap
merge PR, then on the host (c-01):
cd ~/docker/server/c-01/bunyip-api
git pull --ff-only
docker compose up --detach # restart bunyip-api with email off
Then : sign in → clear the 2FA-setup step (self-service TOTP, no email) → you now lands ungated → open /admin/email and confirm/fix SMTP.
Important caveat - re-enabling can re-trap him
SMTP creds are already in env on both deploys and email_enabled=true, so the real symptom is likely the verification mail not delivering to @niceguyit.biz (SMTP_FROM/relay/SPF/DMARC), not SMTP being unset. That matters because:
a. BUNYIP-401 is deployed (admin never needs verification) - the clean fix. Cut a bunyip release after #393 merges. Or
b. verification mail actually delivers (fix SMTP_FROM/relay so @niceguyit.biz accepts it), you clicks verify, then re-enable.