Skip to content

fix(config): make LOGIN_METHODS (and env-mapped config) authoritative over seeded defaults#48

Merged
Bccorb merged 1 commit into
mainfrom
fix/login-methods-env
Jun 28, 2026
Merged

fix(config): make LOGIN_METHODS (and env-mapped config) authoritative over seeded defaults#48
Bccorb merged 1 commit into
mainfrom
fix/login-methods-env

Conversation

@Bccorb

@Bccorb Bccorb commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Problem

Closes #47. LOGIN_METHODS (and other SYSTEM_CONFIG_ENV_MAP vars) had no effect on fresh installs: migration 20260517130000 hard-seeds login_methods, and bootstrapSystemConfig only seeded missing rows — so the env was permanently shadowed.

Fix (three coherent parts)

  1. bootstrapSystemConfig — for env-mapped keys, re-applies the env value over an existing row only when it was never changed through the admin API (updatedBy IS NULL). Admin/runtime overrides (updatedBy set) are preserved. Env-mapped config is now authoritative-by-default on every boot.
  2. Admin update path (updateSystemConfig) — now records updatedBy on upsert (it previously never set it), giving bootstrap a reliable signal to distinguish seeded defaults from admin edits.
  3. Migration 20260628120000 — re-applies LOGIN_METHODS / PASSKEY_LOGIN_FALLBACK_ENABLED to existing un-edited rows so current installs pick up the env immediately.

Verified

  • Unit: added bootstrap tests (env re-applies over un-edited rows; admin-edited rows preserved). Full suite: 484 passing.
  • End-to-end against real Postgres: fresh boot with LOGIN_METHODS=passkey,magic_link,email_otp,phone_otp now yields login_methods = ["passkey","magic_link","email_otp","phone_otp"] in system_config (was stuck at the ["passkey","magic_link"] default).

Note

One-time transition: installs that edited config through the admin API before this change have updatedBy = NULL (the old code never set it), so the first boot after this fix will re-apply their env values over those edits. Going forward, admin edits are marked and preserved.

…faults

bootstrapSystemConfig now re-applies env values over config rows that were never
changed through the admin API (updatedBy IS NULL), so env vars like LOGIN_METHODS
take effect instead of being permanently shadowed by the login-policy migration's
seed. Admin edits now record updatedBy so they're preserved, and a migration
re-applies env to existing un-edited rows.

Closes #47
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.00000% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/config/bootstrapSystemConfig.ts 85.71% 0 Missing and 1 partial ⚠️
src/controllers/systemConfig.ts 0.00% 0 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@Bccorb Bccorb merged commit e050ea2 into main Jun 28, 2026
2 checks passed
@Bccorb Bccorb deleted the fix/login-methods-env branch June 28, 2026 12:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LOGIN_METHODS env is ignored — migration hard-seeds login_methods

2 participants