Stephen
Stephen
BABetter Auth
Created by Stephen on 4/29/2025 in #help
Populate username field with social usernames
No that's all good, thank you for the clarity!
14 replies
BABetter Auth
Created by Stephen on 4/29/2025 in #help
Populate username field with social usernames
I presume I am probably just losing the plot.
14 replies
BABetter Auth
Created by Stephen on 4/29/2025 in #help
Populate username field with social usernames
No description
14 replies
BABetter Auth
Created by Stephen on 4/29/2025 in #help
Populate username field with social usernames
Perhaps I am approaching it wrong?
14 replies
BABetter Auth
Created by Stephen on 4/29/2025 in #help
Populate username field with social usernames
I had assumed so, but I'm not seeing this behaviour: I created an account with that username first, and then signed up with Discord. It doesn't seem to have flagged the duplicate name. Calling here:
await client.signIn.social({
provider,
callbackURL: "/dashboard"
}, {
onError: (ctx) => {
alert(JSON.stringify(ctx))
}
});
await client.signIn.social({
provider,
callbackURL: "/dashboard"
}, {
onError: (ctx) => {
alert(JSON.stringify(ctx))
}
});
Mapper:
discord: {
clientId: DISCORD_CLIENT_ID,
clientSecret: DISCORD_CLIENT_SECRET,
mapProfileToUser: (profile) => {
// Note to self: "name is a requirement in Better Auth. In the future this will be customizable." AKA can't unmap name.
return {
username: profile.username,
displayUsername: profile.username,
};
},
},
discord: {
clientId: DISCORD_CLIENT_ID,
clientSecret: DISCORD_CLIENT_SECRET,
mapProfileToUser: (profile) => {
// Note to self: "name is a requirement in Better Auth. In the future this will be customizable." AKA can't unmap name.
return {
username: profile.username,
displayUsername: profile.username,
};
},
},
14 replies
BABetter Auth
Created by Stephen on 4/29/2025 in #help
Populate username field with social usernames
Thanks! Lastly, I presume I am responsible for handling the uniqueness checks here? I see that it's automatically handled in the client.signUp.email, but it doesn't appear to be here. It's letting me create an account with a username that's already taken so long as I map it in here
14 replies
BABetter Auth
Created by Stephen on 4/29/2025 in #help
Populate username field with social usernames
Just a couple follow ups on this, not seeing it mentioned on those docs 1. Do you know if there's a way to stop a field mapping? For eg, the "name" field is mapping. I tried setting it to undefined and null, neither stopped it. name has no purpose in my project 2. It's a little sticky with username and displayUsername. The username plugin from my understanding has username sanitised to be recognised by system, and displayUsername as the original input. What's the best way for me to map this? I'd need to understand what sanitization is done I think, unless there is a function for this
14 replies
BABetter Auth
Created by Stephen on 4/29/2025 in #help
Populate username field with social usernames
Thank you very much!
14 replies