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 (
ctx: QueryCtx,
userId: Id<'users'>,
): Promise<Doc<'users'>> => {
): Promise<Doc<'users'> | null> => {
const user = await ctx.db.get(userId);
if (!user) throw new ConvexError('User not found.');
return user;
return user ?? null;
};
const getAuthAccountById = async (ctx: QueryCtx, userId: Id<'users'>) => {
const user = await ctx.db.get(userId);
if (!user) throw new ConvexError('User not found.');
if (!user) return null;
const authAccount = await ctx.db
.query('authAccounts')
.withIndex('userIdAndProvider', (q) => q.eq('userId', userId))
.order('desc')
.first();
if (!authAccount) throw new ConvexError('Auth account not found');
return authAccount;
return authAccount ?? null;
};
const getCurrentUserId = async (ctx: QueryCtx) => {
try {
return await getAuthUserId(ctx);
} catch {
return null;
}
};
export const getUserProvider = query({
args: { userId: v.optional(v.id('users')) },
handler: async (ctx, args) => {
const userId = args.userId ?? (await getAuthUserId(ctx));
const userId = args.userId ?? (await getCurrentUserId(ctx));
if (!userId) return null;
const authAccount = await getAuthAccountById(ctx, userId);
return authAccount.provider;
return authAccount?.provider ?? null;
},
});
export const getUser = query({
args: { userId: v.optional(v.id('users')) },
handler: async (ctx, args) => {
const userId = args.userId ?? (await getAuthUserId(ctx));
const userId = args.userId ?? (await getCurrentUserId(ctx));
if (!userId) return null;
return getUserById(ctx, userId);
},