Skip to content

Commit 048a9b0

Browse files
authored
chore: add logging in next-auth (#26404)
* Add logging in next-auth * Add logging at other return
1 parent 60a4d3f commit 048a9b0

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

packages/features/auth/lib/next-auth-options.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1035,7 +1035,12 @@ export const getOptions = ({
10351035
} else {
10361036
return true;
10371037
}
1038-
} else if (existingUserWithEmail.identityProvider === IdentityProvider.CAL) {
1038+
} else if (
1039+
existingUserWithEmail.identityProvider === IdentityProvider.CAL
1040+
) {
1041+
log.error(
1042+
`Userid ${user.id} already exists with CAL identity provider`
1043+
);
10391044
return `/auth/error?error=wrong-provider&provider=${existingUserWithEmail.identityProvider}`;
10401045
} else if (
10411046
existingUserWithEmail.identityProvider === IdentityProvider.GOOGLE &&
@@ -1064,6 +1069,17 @@ export const getOptions = ({
10641069
return true;
10651070
}
10661071
}
1072+
log.error(
1073+
`Userid ${user.id} trying to login with the wrong provider`,
1074+
{
1075+
userId: user.id,
1076+
account: {
1077+
providerAccountId: account?.providerAccountId,
1078+
type: account?.type,
1079+
provider: account?.provider,
1080+
},
1081+
}
1082+
);
10671083
return `/auth/error?error=wrong-provider&provider=${existingUserWithEmail.identityProvider}`;
10681084
}
10691085

0 commit comments

Comments
 (0)