From 45d2461781b6c37cff501f1a7a829b23354124ea Mon Sep 17 00:00:00 2001 From: gibbyb Date: Fri, 19 Sep 2025 16:57:59 -0500 Subject: [PATCH] Want to remove reset password field if provider is not password. almost there --- packages/backend/convex/auth.ts | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/packages/backend/convex/auth.ts b/packages/backend/convex/auth.ts index 662f2f4..8dee6e8 100644 --- a/packages/backend/convex/auth.ts +++ b/packages/backend/convex/auth.ts @@ -33,28 +33,29 @@ export const getUser = query(async (ctx) => { typeof user.image === 'string' && user.image.length > 0 ? (user.image as Id<'_storage'>) : null; + const authAccount = await ctx.db + .query('authAccounts') + .withIndex('userIdAndProvider', (q) => q.eq('userId', userId)) + .first(); return { id: user._id, - email: user.email ?? null, - name: user.name ?? null, + email: user?.email, + name: user?.name, image, - lunchTime: user.lunchTime ?? null, - automaticLunch: user.automaticLunch ?? false, + lunchTime: user?.lunchTime, + automaticLunch: user.automaticLunch, + provider: authAccount?.provider, }; }); -// Add this temporarily to packages/backend/convex/auth.ts -export const debugMicrosoftConfig = action({ - args: {}, - handler: async (ctx, args) => { - console.log('Microsoft Entra ID Config Debug:', { - issuer: process.env.AUTH_MICROSOFT_ENTRA_ID_ISSUER, - clientId: process.env.AUTH_MICROSOFT_ENTRA_ID_ID, - hasSecret: !!process.env.AUTH_MICROSOFT_ENTRA_ID_SECRET, - secretLength: process.env.AUTH_MICROSOFT_ENTRA_ID_SECRET?.length, - }); - return { logged: true }; - }, +export const getUserAuthAccount = query(async (ctx) => { + const userId = await getAuthUserId(ctx); + if (!userId) return null; + const authAccount = await ctx.db + .query('authAccounts') + .withIndex('userIdAndProvider', (q) => q.eq('userId', userId)) + .first(); + return authAccount; }); export const getAllUsers = query(async (ctx) => {