Skip to content

Commit c399ca5

Browse files
committed
fix: mapProfileToUser getting called twice during idToken login
1 parent 93c4eef commit c399ca5

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

packages/better-auth/src/api/routes/sign-in.ts

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -263,14 +263,7 @@ export const signInSocial = createAuthEndpoint(
263263
message: BASE_ERROR_CODES.FAILED_TO_GET_USER_INFO,
264264
});
265265
}
266-
const mapProfileToUser = await provider.options?.mapProfileToUser?.(
267-
userInfo.user,
268-
);
269-
const userData = {
270-
...userInfo.user,
271-
...mapProfileToUser,
272-
};
273-
if (!userData.email) {
266+
if (!userInfo.user.email) {
274267
c.context.logger.error("User email not found", {
275268
provider: c.body.provider,
276269
});
@@ -280,12 +273,12 @@ export const signInSocial = createAuthEndpoint(
280273
}
281274
const data = await handleOAuthUserInfo(c, {
282275
userInfo: {
283-
...userData,
284-
email: userData.email,
285-
id: userData.id,
286-
name: userData.name || "",
287-
image: userData.image,
288-
emailVerified: userData.emailVerified || false,
276+
...userInfo.user,
277+
email: userInfo.user.email,
278+
id: userInfo.user.id,
279+
name: userInfo.user.name || "",
280+
image: userInfo.user.image,
281+
emailVerified: userInfo.user.emailVerified || false,
289282
},
290283
account: {
291284
providerId: provider.id,

0 commit comments

Comments
 (0)