Skip to content

Commit 89416fe

Browse files
authored
Merge pull request #3685 from Dokploy/feat/add-trusted-providers-dinamically
feat(auth): dynamically add trusted providers for account linking
2 parents a24dbe3 + 74d72f1 commit 89416fe

1 file changed

Lines changed: 12 additions & 11 deletions

File tree

packages/server/src/lib/auth.ts

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ import { getHubSpotUTK, submitToHubSpot } from "../utils/tracking/hubspot";
1818
import { sendEmail } from "../verification/send-verification-email";
1919
import { getPublicIpWithFallback } from "../wss/utils";
2020

21+
const query = await db.query.ssoProvider.findMany();
22+
23+
const trustedProviders = query.map((provider) => provider.providerId);
24+
2125
const { handler, api } = betterAuth({
2226
database: drizzleAdapter(db, {
2327
provider: "pg",
@@ -43,17 +47,14 @@ const { handler, api } = betterAuth({
4347
},
4448
}
4549
: {}),
46-
...(IS_CLOUD
47-
? {
48-
account: {
49-
accountLinking: {
50-
enabled: true,
51-
trustedProviders: ["github", "google"],
52-
allowDifferentEmails: true,
53-
},
54-
},
55-
}
56-
: {}),
50+
51+
account: {
52+
accountLinking: {
53+
enabled: true,
54+
trustedProviders: ["github", "google", ...(trustedProviders || [])],
55+
allowDifferentEmails: true,
56+
},
57+
},
5758
appName: "Dokploy",
5859
socialProviders: {
5960
github: {

0 commit comments

Comments
 (0)