fix: root directory creation

Co-authored-by: Ona <no-reply@ona.com>
This commit is contained in:
2025-10-05 22:14:44 +00:00
parent 1fcdaf4f86
commit f7bc5fd958
14 changed files with 95 additions and 107 deletions

View File

@@ -3,13 +3,26 @@ import { convex, crossDomain } from "@convex-dev/better-auth/plugins"
import { betterAuth } from "better-auth"
import { components } from "./_generated/api"
import type { DataModel } from "./_generated/dataModel"
import { query } from "./_generated/server"
const siteUrl = process.env.SITE_URL!
// The component client has methods needed for integrating Convex with Better Auth,
// as well as helper methods for general use.
export const authComponent = createClient<DataModel>(components.betterAuth)
export const authComponent = createClient<DataModel>(components.betterAuth, {
triggers: {
user: {
onCreate: async (ctx, user) => {
const now = Date.now()
await ctx.db.insert("directories", {
name: "",
userId: user._id,
createdAt: now,
updatedAt: now,
})
},
},
},
})
export const createAuth = (
ctx: GenericCtx<DataModel>,
@@ -36,12 +49,3 @@ export const createAuth = (
],
})
}
// Example function for getting the current user
// Feel free to edit, omit, etc.
export const getCurrentUser = query({
args: {},
handler: async (ctx) => {
return authComponent.getAuthUser(ctx)
},
})