feat(auth): dynamically add trusted providers for account linking

- Updated the account linking configuration to include trusted providers fetched from the database, enhancing flexibility in managing SSO integrations.
This commit is contained in:
Mauricio Siu
2026-02-10 23:47:21 -06:00
parent a24dbe365a
commit 74d72f1494

View File

@@ -18,6 +18,10 @@ import { getHubSpotUTK, submitToHubSpot } from "../utils/tracking/hubspot";
import { sendEmail } from "../verification/send-verification-email";
import { getPublicIpWithFallback } from "../wss/utils";
const query = await db.query.ssoProvider.findMany();
const trustedProviders = query.map((provider) => provider.providerId);
const { handler, api } = betterAuth({
database: drizzleAdapter(db, {
provider: "pg",
@@ -43,17 +47,14 @@ const { handler, api } = betterAuth({
},
}
: {}),
...(IS_CLOUD
? {
account: {
accountLinking: {
enabled: true,
trustedProviders: ["github", "google"],
allowDifferentEmails: true,
},
},
}
: {}),
account: {
accountLinking: {
enabled: true,
trustedProviders: ["github", "google", ...(trustedProviders || [])],
allowDifferentEmails: true,
},
},
appName: "Dokploy",
socialProviders: {
github: {