Discord OAuth Issue

I'm recreating this post but with much less rambling than our old post to make it more digestible. (https://discord.com/channels/1288403910284935179/1383602900923842660) We have a huge bug with BA. Every time a user OAuths (a) using ONLY Discord and (b) ONLY on prod, a brand new account/user is generated. This does NOT happen locally, or with email/pass/other oauth providers. X Any help please?
22 Replies
Stephen
StephenOP3mo ago
@Ping Any insight?
Ping
Ping3mo ago
@Stephen Is it both a new account & a new user?
Stephen
StephenOP3mo ago
Just checked - it is indeed a brand new account and user per sign in
Ping
Ping3mo ago
Am I able to see screenshots of your DB? Would like to see both users on the user table created via discord oauth. And also account table of the two users too, thanks.
Stephen
StephenOP3mo ago
Yes sir, just logged in twice to generate two new accounts. Here they are:
No description
No description
Ping
Ping3mo ago
Just want to make sure, both emails are the same right?
Stephen
StephenOP3mo ago
Yes sir, identical, blocked out for obvious reasons :) This is why it's so strange. Logging in with the exact same Discord account! Not just mine too by the way, applies to all Discord accounts
Ping
Ping3mo ago
I wonder if it has something to do with your prod. Lots of people use Discord oauth but I've never seen such an issue. Are you using a VPS or some cloud provider?
Stephen
StephenOP3mo ago
We also find it very strange how this is only happening in prod. Locally, I log into my existing account just fine! Paging in @Dawson, any insight here? At a high level we're using Dokploy on a VPS
Dawson
Dawson3mo ago
Yea VPS, could it be the env somehow? it’s running in a docker container, same docker file as it always has (and we think it worked in the past) the env should be the same but who knows
Stephen
StephenOP3mo ago
@Ping So this is our setup. I know we're clutching at straws but I'm not seeing really any obvious reason this would only be happening with Discord, even though this does only happen on prod. Is there any other info we could give you? Happy to share anything As we really need to get this fixed, our app is live w/ users
Ping
Ping3mo ago
Just alerted Bekacru, as I'm not sure of the cause 🤔
bekacru
bekacru3mo ago
confirm me you're on latest and also are you using mongodb locally?
Dawson
Dawson3mo ago
We’re using two different mongo instances (different containers) hosted on the same VPS. Both access using user + pass auth via ip and port (External URLs for both) Under the same prod mongo instance under a different database name we have another app using discord oauth and it seems to work fine
bekacru
bekacru3mo ago
can you try npm i https://pkg.pr.new/better-auth/better-auth@3038 this version? I couldn't reproduce it either but the only reason a user would be re-registed is if the db didn't return a user with the email or providerId+accountId
Dawson
Dawson3mo ago
cc @Stephen not home for another ~1.5 hrs
Stephen
StephenOP3mo ago
Working ok locally, pushing now @bekacru IT WORKED!!! I'm now logging into my first and original Discord account! Thank you so much. What was the fix??
bekacru
bekacru3mo ago
my guess is and check on the mongodb adapter wasn't poroperly working (maybe) were you on latest both prod and dev?
Stephen
StephenOP3mo ago
We were on 1.2.9 Thank you so much
bekacru
bekacru3mo ago
npm i https://pkg.pr.new/better-auth/better-auth@bfe4c37 try this version, since the last one includes something we're losing by going that route
Stephen
StephenOP3mo ago
Working!

Did you find this page helpful?