Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0829f9ffa2 |
+16
-18
@@ -1,7 +1,6 @@
|
|||||||
import { betterAuth } from "better-auth";
|
import { betterAuth } from "better-auth";
|
||||||
import { drizzleAdapter } from "better-auth/adapters/drizzle";
|
import { drizzleAdapter } from "better-auth/adapters/drizzle";
|
||||||
import { genericOAuth } from "better-auth/plugins";
|
import { genericOAuth } from "better-auth/plugins";
|
||||||
import { google, github } from "better-auth/social-providers";
|
|
||||||
import { getDb, authProviderConfig, eq } from "@groombook/db";
|
import { getDb, authProviderConfig, eq } from "@groombook/db";
|
||||||
import { decryptSecret } from "@groombook/db";
|
import { decryptSecret } from "@groombook/db";
|
||||||
|
|
||||||
@@ -173,22 +172,6 @@ export async function initAuth(): Promise<void> {
|
|||||||
|
|
||||||
const callbackBase = `${BETTER_AUTH_URL}/api/auth/callback`;
|
const callbackBase = `${BETTER_AUTH_URL}/api/auth/callback`;
|
||||||
|
|
||||||
const socialPlugins = [];
|
|
||||||
if (hasGoogle) {
|
|
||||||
socialPlugins.push(google({
|
|
||||||
clientId: process.env.GOOGLE_CLIENT_ID!,
|
|
||||||
clientSecret: process.env.GOOGLE_CLIENT_SECRET!,
|
|
||||||
redirectURI: `${callbackBase}/google`,
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
if (hasGitHub) {
|
|
||||||
socialPlugins.push(github({
|
|
||||||
clientId: process.env.GITHUB_CLIENT_ID!,
|
|
||||||
clientSecret: process.env.GITHUB_CLIENT_SECRET!,
|
|
||||||
redirectURI: `${callbackBase}/github`,
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Build Better-Auth instance using resolved config
|
// Build Better-Auth instance using resolved config
|
||||||
authInstance = betterAuth({
|
authInstance = betterAuth({
|
||||||
database: drizzleAdapter(db, {
|
database: drizzleAdapter(db, {
|
||||||
@@ -196,6 +179,22 @@ export async function initAuth(): Promise<void> {
|
|||||||
}),
|
}),
|
||||||
secret: BETTER_AUTH_SECRET,
|
secret: BETTER_AUTH_SECRET,
|
||||||
baseURL: BETTER_AUTH_URL,
|
baseURL: BETTER_AUTH_URL,
|
||||||
|
socialProviders: {
|
||||||
|
...(hasGoogle ? {
|
||||||
|
google: {
|
||||||
|
clientId: process.env.GOOGLE_CLIENT_ID!,
|
||||||
|
clientSecret: process.env.GOOGLE_CLIENT_SECRET!,
|
||||||
|
redirectURI: `${callbackBase}/google`,
|
||||||
|
},
|
||||||
|
} : {}),
|
||||||
|
...(hasGitHub ? {
|
||||||
|
github: {
|
||||||
|
clientId: process.env.GITHUB_CLIENT_ID!,
|
||||||
|
clientSecret: process.env.GITHUB_CLIENT_SECRET!,
|
||||||
|
redirectURI: `${callbackBase}/github`,
|
||||||
|
},
|
||||||
|
} : {}),
|
||||||
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
genericOAuth({
|
genericOAuth({
|
||||||
config: [
|
config: [
|
||||||
@@ -216,7 +215,6 @@ export async function initAuth(): Promise<void> {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
...socialPlugins,
|
|
||||||
],
|
],
|
||||||
session: {
|
session: {
|
||||||
expiresIn: 60 * 60 * 24 * 7, // 7 days
|
expiresIn: 60 * 60 * 24 * 7, // 7 days
|
||||||
|
|||||||
Reference in New Issue
Block a user