mapProfileToUser doesnt work

I have a problem: mapProfileToUser doesn’t work when I want to grab and save my user’s Discord ID as identifier in the session. When I print the profile, it contains the id (which is the Discord ID) property. However, when I print my session user, there is no identifier property. auth.ts
export const auth = betterAuth({
database: createPool({
host: x,
user: x,
password: x,
database: x,
}),
socialProviders: {
discord: {
clientId: process.env.DISCORD_CLIENT_ID as string,
clientSecret: process.env.DISCORD_CLIENT_SECRET as string,
mapProfileToUser: (profile) => {
console.log(profile)
return {
identifier: profile.id
};
}
}
},
secret: process.env.BETTER_AUTH_SECRET as string,
[...]
export const auth = betterAuth({
database: createPool({
host: x,
user: x,
password: x,
database: x,
}),
socialProviders: {
discord: {
clientId: process.env.DISCORD_CLIENT_ID as string,
clientSecret: process.env.DISCORD_CLIENT_SECRET as string,
mapProfileToUser: (profile) => {
console.log(profile)
return {
identifier: profile.id
};
}
}
},
secret: process.env.BETTER_AUTH_SECRET as string,
[...]
3 Replies
Byron
Byron4mo ago
Did you figure this out?
Kiwi
Kiwi3mo ago
@45dusz_ek
Byron
Byron3mo ago
Figured this out mark so solved if it helps you: https://github.com/better-auth/better-auth/issues/2713
GitHub
mapProfileToUser not working · Issue #2713 · better-auth/better...
Is this suited for github? Yes, this is suited for github To Reproduce Implement Sign in with GitHub Add additional field to users (github) on prisma schema etc. Try map the username which is logge...

Did you find this page helpful?