Update stuff so we can pass build hopefully
Build and Push Next App / quality (push) Successful in 1m32s
Build and Push Next App / build-next (push) Successful in 42s

This commit is contained in:
Gabriel Brown
2026-06-21 22:32:02 -05:00
parent 48071d1afe
commit 112fd55ea7
+15 -9
View File
@@ -35,36 +35,42 @@ export const { auth, signIn, signOut, store, isAuthenticated } = convexAuth({
const getUserById = async ( const getUserById = async (
ctx: QueryCtx, ctx: QueryCtx,
userId: Id<'users'>, userId: Id<'users'>,
): Promise<Doc<'users'>> => { ): Promise<Doc<'users'> | null> => {
const user = await ctx.db.get(userId); const user = await ctx.db.get(userId);
if (!user) throw new ConvexError('User not found.'); return user ?? null;
return user;
}; };
const getAuthAccountById = async (ctx: QueryCtx, userId: Id<'users'>) => { const getAuthAccountById = async (ctx: QueryCtx, userId: Id<'users'>) => {
const user = await ctx.db.get(userId); const user = await ctx.db.get(userId);
if (!user) throw new ConvexError('User not found.'); if (!user) return null;
const authAccount = await ctx.db const authAccount = await ctx.db
.query('authAccounts') .query('authAccounts')
.withIndex('userIdAndProvider', (q) => q.eq('userId', userId)) .withIndex('userIdAndProvider', (q) => q.eq('userId', userId))
.order('desc') .order('desc')
.first(); .first();
if (!authAccount) throw new ConvexError('Auth account not found'); return authAccount ?? null;
return authAccount; };
const getCurrentUserId = async (ctx: QueryCtx) => {
try {
return await getAuthUserId(ctx);
} catch {
return null;
}
}; };
export const getUserProvider = query({ export const getUserProvider = query({
args: { userId: v.optional(v.id('users')) }, args: { userId: v.optional(v.id('users')) },
handler: async (ctx, args) => { handler: async (ctx, args) => {
const userId = args.userId ?? (await getAuthUserId(ctx)); const userId = args.userId ?? (await getCurrentUserId(ctx));
if (!userId) return null; if (!userId) return null;
const authAccount = await getAuthAccountById(ctx, userId); const authAccount = await getAuthAccountById(ctx, userId);
return authAccount.provider; return authAccount?.provider ?? null;
}, },
}); });
export const getUser = query({ export const getUser = query({
args: { userId: v.optional(v.id('users')) }, args: { userId: v.optional(v.id('users')) },
handler: async (ctx, args) => { handler: async (ctx, args) => {
const userId = args.userId ?? (await getAuthUserId(ctx)); const userId = args.userId ?? (await getCurrentUserId(ctx));
if (!userId) return null; if (!userId) return null;
return getUserById(ctx, userId); return getUserById(ctx, userId);
}, },