how can i prevent discord auth to automatically create new accounts?

basically i want the user to be able to sign in with discord only after he linked his discord account
Solution:
haven't tried it but seems like you just set it to false and it does what you want
Jump to solution
15 Replies
david
davidOP3mo ago
discord: {
clientId: process.env.DISCORD_CLIENT_ID as string,
clientSecret: process.env.DISCORD_CLIENT_SECRET as string,
disableImplicitSignUp: true,
disableSignUp: true,
},
discord: {
clientId: process.env.DISCORD_CLIENT_ID as string,
clientSecret: process.env.DISCORD_CLIENT_SECRET as string,
disableImplicitSignUp: true,
disableSignUp: true,
},
tried doing this but it doesn't work
WiFi Plug
WiFi Plug3mo ago
Isn't signing up with discord technically linking their discord account?
david
davidOP3mo ago
so here's what i want to do
WiFi Plug
WiFi Plug3mo ago
can't you just make it when they signup with discord that discord is then "linked" however you define that to their account whether that be storing something in the database
david
davidOP3mo ago
the user can opt to login with discord or email:pass but in order to login with discord they have to link it first cuz i want to have all base accounts as credentials i want to disallow discord sign ups that's the thing and for some reasons
const signInWithDiscord = async () => {
await authClient.signIn.social({
provider: "discord",
callbackURL: "/dashboard",
requestSignUp: false,
});
};
const signInWithDiscord = async () => {
await authClient.signIn.social({
provider: "discord",
callbackURL: "/dashboard",
requestSignUp: false,
});
};
this is creating a new user account if betterauth doesn't find any account with that discord id OH
david
davidOP3mo ago
No description
david
davidOP3mo ago
it seems that i had something cached in incognito??
WiFi Plug
WiFi Plug3mo ago
ah maybe or maybe your dev server didnt reload or something
david
davidOP3mo ago
no still doesn't work wtf oh i found an issue if a user has his email the same with discord it will link his account directly tf
WiFi Plug
WiFi Plug3mo ago
Yeah that's generally preferred for most sites so they can login with either one as long as it's the same email
david
davidOP3mo ago
and is there any way to disable that?
WiFi Plug
WiFi Plug3mo ago
yeah
david
davidOP3mo ago
ohhh so i dont have to set that to true
Solution
WiFi Plug
WiFi Plug3mo ago
haven't tried it but seems like you just set it to false and it does what you want

Did you find this page helpful?