fix(config): make LOGIN_METHODS (and env-mapped config) authoritative over seeded defaults#48
Merged
Merged
Conversation
…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 Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Closes #47.
LOGIN_METHODS(and otherSYSTEM_CONFIG_ENV_MAPvars) had no effect on fresh installs: migration20260517130000hard-seedslogin_methods, andbootstrapSystemConfigonly seeded missing rows — so the env was permanently shadowed.Fix (three coherent parts)
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 (updatedByset) are preserved. Env-mapped config is now authoritative-by-default on every boot.updateSystemConfig) — now recordsupdatedByon upsert (it previously never set it), giving bootstrap a reliable signal to distinguish seeded defaults from admin edits.20260628120000— re-appliesLOGIN_METHODS/PASSKEY_LOGIN_FALLBACK_ENABLEDto existing un-edited rows so current installs pick up the env immediately.Verified
LOGIN_METHODS=passkey,magic_link,email_otp,phone_otpnow yieldslogin_methods = ["passkey","magic_link","email_otp","phone_otp"]insystem_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.