mirror of
https://github.com/get-drexa/drive.git
synced 2025-12-01 05:51:39 +00:00
@@ -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)
|
||||
},
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user