Open-Assistant icon indicating copy to clipboard operation
Open-Assistant copied to clipboard

Allow a user to link their Discord account after registering with email

Open fozziethebeat opened this issue 3 years ago • 5 comments

NextAuthJS makes this a little hard. Ideally a user should be able to sign up via email and then at some later date link in their Discord account. This should update the website's account database with those discord credentials so we can then associate their contributions with their discord id from that point on.

I'm not 100% sure how to do this so if anyone wants to dive deep into NextAuthJS and figure this out (or do something a little custom that fits within NextAuthJS) that'll be a big help.

fozziethebeat avatar Dec 28 '22 07:12 fozziethebeat

I decided to do a bit of digging and it turns out it’s actually quite a hassle to implement multi-provider logins for nextauth as seen in this discussion Multiple accounts with same mail handling #2808, but there seems to be a built-in work around that seems to solve it but i have yet to actually test it.

To get it to work the user must use the same email for both open assistant and discord and enable allowDangerousEmailAccountLinking: true in the provider configuration as seen in the docs here and here

based on the docs I assume it should look something like this in our [..nextauth.ts]

 providers.push(
    DiscordProvider({
      clientId: process.env.DISCORD_CLIENT_ID,
      clientSecret: process.env.DISCORD_CLIENT_SECRET,
      allowDangerousEmailAccountLinking: true
    })
  );
}

poipiii avatar Dec 31 '22 13:12 poipiii

If this hasn't already been implemented into the codebase by @poipiii, I'd be happy to do a pull request to do this work at some point over this week?

callum-gander avatar Jan 09 '23 14:01 callum-gander

Sure, I haven't seen a PR for this yet so it's open for someone to look at

fozziethebeat avatar Jan 09 '23 23:01 fozziethebeat

Got held up this weekend, going to do this tonight, sorry for the delay

callum-gander avatar Jan 17 '23 10:01 callum-gander

Unassigned myself, I ran into errors when I tried to do this, not sure why and I don't have time to debug. Apologies, should have unassigned myself from this earlier

callum-gander avatar Jan 30 '23 17:01 callum-gander

No worries, I'm actually going to close this as we're changing how auth works and will fix it via that update.

fozziethebeat avatar Jan 31 '23 07:01 fozziethebeat