db: push sso changes

This commit is contained in:
2026-01-14 03:24:30 -05:00
parent 1cf3dc4d6f
commit ea9dc35323
3 changed files with 21 additions and 2 deletions

View File

@@ -87,8 +87,8 @@ export function SettingsContent() {
const handleLinkAuthentik = async () => {
setIsLinking(true);
try {
await authClient.linkSocial({
provider: "authentik",
await authClient.signIn.sso({
domain: "beenvoice.soconnor.dev",
callbackURL: "/dashboard/settings",
});
} catch (error) {

View File

@@ -13,6 +13,7 @@ export const auth = betterAuth({
session: schema.sessions,
account: schema.accounts,
verification: schema.verificationTokens,
ssoProvider: schema.ssoProviders,
},
}),
trustedOrigins: [
@@ -60,6 +61,9 @@ export const auth = betterAuth({
jwksEndpoint: "https://auth.soconnor.dev/application/o/beenvoice/jwks/",
scopes: ["openid", "email", "profile"],
pkce: true,
mapping: {
emailVerified: "email_verified",
},
},
},
]

View File

@@ -106,6 +106,21 @@ export const verificationTokens = createTable(
(t) => [index("verification_token_identifier_idx").on(t.identifier)],
);
export const ssoProviders = createTable(
"sso_provider",
(d) => ({
id: d.varchar({ length: 255 }).notNull().primaryKey().$defaultFn(() => crypto.randomUUID()),
providerId: d.varchar({ length: 255 }).notNull().unique(),
userId: d.varchar({ length: 255 }).notNull().references(() => users.id),
redirectURI: d.varchar({ length: 255 }).notNull().default(""), // Added detailed fields
oidcConfig: d.text(),
samlConfig: d.text(),
createdAt: d.timestamp().notNull().defaultNow(),
updatedAt: d.timestamp().notNull().defaultNow().$onUpdate(() => new Date()),
}),
(t) => [index("sso_provider_user_id_idx").on(t.userId)],
);
// Invoicing app tables
export const clients = createTable(
"client",