import { query } from "./_generated/server"; import { getAuthUserId } from "@convex-dev/auth/server"; export const getCurrent = query({ args: {}, handler: async (ctx) => { const userId = await getAuthUserId(ctx); if (!userId) return null; return await ctx.db.get(userId); }, }); export const getCurrentProfile = query({ args: {}, handler: async (ctx) => { const userId = await getAuthUserId(ctx); if (!userId) return null; const user = await ctx.db.get(userId); if (!user) return null; const accounts = await ctx.db .query("authAccounts") .withIndex("userIdAndProvider", (q) => q.eq("userId", userId)) .collect(); return { user, accounts }; }, });