diff --git a/src/app/jams/jam/[jam]/page.tsx b/src/app/jams/jam/[jam]/page.tsx index a8949f7..8ec8b1f 100644 --- a/src/app/jams/jam/[jam]/page.tsx +++ b/src/app/jams/jam/[jam]/page.tsx @@ -95,15 +95,16 @@ export default async function Home({
Hosted by {`${jamOwner.username}@${jamOwner.instance}`}
{jam.description}
If you'd like to participate in this jam, you should join!
-You'll also be able to participate an any future jams should they come to fruition.
-To join with GitHub instead, enter "github.com".
+If you'd like to participate in any jam, you should join!
+To join with the Fediverse, enter your instance domain.
+ To join with GitHub, enter "github.com".
+ To join with Discord, enter "discord.com".
Tested on GitHub, Mastodon, GoToSocial, Pleroma, and Misskey
+Tested on Discord, GitHub, Mastodon, GoToSocial, Pleroma, and Misskey
These serve many purposes. To create a community bond, to help creatives find their way, and most importantly, to make me popular. X3
Enjoy!
If you'd like to participate in any jam, you should join!
-To join with GitHub, enter "github.com".
+To join with the Fediverse, enter your instance domain.
+ To join with GitHub, enter "github.com".
+ To join with Discord, enter "discord.com".
Tested on GitHub, Mastodon, GoToSocial, Pleroma, and Misskey
+Tested on Discord, GitHub, Mastodon, GoToSocial, Pleroma, and Misskey
Logged in as {existingUser?.username}@{existingUser?.instance} (Logout)
diff --git a/src/lib/mastoauth/mastoauth.ts b/src/lib/mastoauth/mastoauth.ts index 264c793..3b15cfd 100644 --- a/src/lib/mastoauth/mastoauth.ts +++ b/src/lib/mastoauth/mastoauth.ts @@ -76,12 +76,22 @@ export class MastoAuth { if (this.instance != "github.com") formData.append('grant_type', 'authorization_code'); formData.append('code', code); - if (this.instance != "github.com") + if (this.instance == "discord.com") + formData.append('scope', 'identify'); + else if (this.instance != "github.com") formData.append('scope', 'read'); let appRequest; try { - if (this.instance == "github.com") { + if (this.instance == "discord.com") { + appRequest = await fetch(`https://${this.instance}/api/v10/oauth2/token`, { + body: formData, + method: "post", + headers: { + "Accept": "application/json" + } + }); + } else if (this.instance == "github.com") { appRequest = await fetch(`https://${this.instance}/login/oauth/access_token`, { body: formData, method: "post", @@ -96,6 +106,7 @@ export class MastoAuth { }); } } catch (err) { + console.log(err); return null; } @@ -113,7 +124,13 @@ export class MastoAuth { async verifyUser(auth: string) { let appRequest; try { - if (this.instance == "github.com") { + if (this.instance == "discord.com") { + appRequest = await fetch(`https://${this.instance}/api/v10/oauth2/@me`, { + headers: { + "Authorization": auth + } + }); + } else if (this.instance == "github.com") { appRequest = await fetch(`https://api.${this.instance}/user`, { headers: { "Authorization": auth @@ -127,6 +144,7 @@ export class MastoAuth { }); } } catch (err) { + console.log(err); return null; }