Skip to content

Commit 9780863

Browse files
therealbradclaude
andcommitted
fix(auth): preserve Magic Link provider settings on pod restart
The seed upsert was overwriting `enabled` and `forceSso` back to false on every pod restart, undoing the provisioning script's SQL update that enables Magic Link for new trial instances. This caused newly provisioned instances to show the password login form instead of the magic link sign-in. Remove `enabled` and `forceSso` from the update block so the seed only sets those fields on initial creation. Existing runtime config set by the provisioning script is now preserved across restarts. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 5c8bb9b commit 9780863

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

testplanit/prisma/seed.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3587,27 +3587,29 @@ async function main() {
35873587
if (process.env.NODE_ENV === "production") {
35883588
try {
35893589
console.log("Seeding production SSO provider...");
3590-
// Create Magic Link provider (disabled by default to prevent unwanted emails)
3590+
// Create Magic Link provider if it doesn't exist (disabled by default).
3591+
// The update block intentionally does NOT touch `enabled` or `forceSso`
3592+
// because the provisioning script sets those after seeding and we must
3593+
// not overwrite them on subsequent pod restarts.
35913594
await prisma.ssoProvider.upsert({
35923595
where: {
35933596
name: "Magic Link",
35943597
},
35953598
update: {
35963599
type: "MAGIC_LINK",
3597-
enabled: false, // Disabled by default - must be manually enabled
3598-
forceSso: false, // Allow both SSO and regular signup
3600+
// Do NOT set enabled or forceSso here — preserve runtime config
35993601
config: {},
36003602
},
36013603
create: {
36023604
name: "Magic Link",
36033605
type: "MAGIC_LINK",
3604-
enabled: false, // Disabled by default - must be manually enabled
3605-
forceSso: false, // Allow both SSO and regular signup
3606+
enabled: false, // Disabled by default - provisioning script enables it
3607+
forceSso: false, // Provisioning script sets this to true
36063608
config: {},
36073609
},
36083610
});
36093611
console.log(
3610-
`✓ Created Magic Link provider (disabled by default - must be manually enabled in admin settings)`
3612+
`✓ Magic Link provider ensured (existing settings preserved, new instances start disabled)`
36113613
);
36123614
} catch (error) {
36133615
console.error("Error seeding SSO provider (continuing):", error);

0 commit comments

Comments
 (0)