From 048a9b04fa27df404dd2c1fc620cc8da3ce863b5 Mon Sep 17 00:00:00 2001 From: Joe Au-Yeung <65426560+joeauyeung@users.noreply.github.com> Date: Fri, 2 Jan 2026 18:30:09 -0500 Subject: [PATCH] chore: add logging in next-auth (#26404) * Add logging in next-auth * Add logging at other return --- .../features/auth/lib/next-auth-options.ts | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/packages/features/auth/lib/next-auth-options.ts b/packages/features/auth/lib/next-auth-options.ts index 373ccd11ab5a26..0767004b9d5632 100644 --- a/packages/features/auth/lib/next-auth-options.ts +++ b/packages/features/auth/lib/next-auth-options.ts @@ -1035,7 +1035,12 @@ export const getOptions = ({ } else { return true; } - } else if (existingUserWithEmail.identityProvider === IdentityProvider.CAL) { + } else if ( + existingUserWithEmail.identityProvider === IdentityProvider.CAL + ) { + log.error( + `Userid ${user.id} already exists with CAL identity provider` + ); return `/auth/error?error=wrong-provider&provider=${existingUserWithEmail.identityProvider}`; } else if ( existingUserWithEmail.identityProvider === IdentityProvider.GOOGLE && @@ -1064,6 +1069,17 @@ export const getOptions = ({ return true; } } + log.error( + `Userid ${user.id} trying to login with the wrong provider`, + { + userId: user.id, + account: { + providerAccountId: account?.providerAccountId, + type: account?.type, + provider: account?.provider, + }, + } + ); return `/auth/error?error=wrong-provider&provider=${existingUserWithEmail.identityProvider}`; }