Skip to content
This repository was archived by the owner on Oct 7, 2025. It is now read-only.

Commit b8759a4

Browse files
committed
feat(axiom): implement discord auth
1 parent 0f8abc7 commit b8759a4

File tree

5 files changed

+51
-24
lines changed

5 files changed

+51
-24
lines changed

apps/axiom/src/components/AfterLogin/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,12 @@ export function OAuthButtons() {
2828
/>
2929
<OAuthButton
3030
href="/api/users/oauth/github"
31-
iconSrc="https://cdn.jsdelivr.net/gh/devicons/devicon@latest/icons/github/github-original.svg"
31+
iconSrc="https://cdn.jsdelivr.net/gh/devicons/devicon@latest/icons/github/github-original.svg"
3232
bgColor="green"
3333
altText="GitHub Login"
3434
/>
3535
<OAuthButton
36-
// href="/api/users/oauth/discord"
37-
href="https://www.youtube.com/watch?v=dQw4w9WgXcQ"
36+
href="/api/users/oauth/discord"
3837
iconSrc="https://cdn.prod.website-files.com/6257adef93867e50d84d30e2/636e0a69f118df70ad7828d4_icon_clyde_blurple_RGB.svg"
3938
bgColor="#1e2124"
4039
altText="Discord Login"
@@ -75,6 +74,7 @@ const buttonStyles = {
7574
fontSize: '16px',
7675
fontWeight: 'bold',
7776
borderRadius: '5px',
77+
transition: 'all 750ms ease-in-out',
7878
};
7979

8080
const iconStyle = {

libs/cms/auth/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export const discordStrategyConfig = {
5454
subFieldName: 'discordSub',
5555
clientId: process.env.DISCORD_CLIENT_ID || "",
5656
clientSecret: process.env.DISCORD_CLIENT_SECRET || "",
57-
authorizePath: "/oauth2/authorize",
57+
authorizePath: "/oauth/discord",
5858
callbackPath: "/oauth/discord/callback",
5959
tokenEndpoint: "https://discord.com/api/oauth2/token",
6060
providerAuthorizationUrl: "https://discord.com/oauth2/authorize",

libs/cms/auth/strategies/discord.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,23 @@ export const discordOAuth = OAuth2Plugin({
88
scopes: [
99
"identify",
1010
"email",
11-
"openid"
1211
],
1312
getUserInfo: async (accessToken: string, req: PayloadRequest) => {
1413
const response = await fetch(
15-
`https://discord.com/api/v10`,
14+
`https://discord.com/api/v10/users/@me`,
1615
{ headers: { Authorization: `Bearer ${accessToken}` } },
1716
);
17+
console.log(accessToken)
1818
const user = await response.json();
1919

2020
return {
21-
// email: user.email,
22-
// firstName: user.given_name,
23-
// lastName: user.family_name,
24-
// displayName: user.name,
25-
// mediaUrl: user.picture,
26-
// discordSub: user.sub,
21+
email: user.email,
22+
discordUsername: user.username,
23+
discordVerified: user.verified,
24+
discordDiscriminator: user.discriminator,
25+
discordId: user.id,
26+
discordGlobalName: user.global_name,
27+
discordLocale: user.locale,
2728
};
2829
},
2930
...discordStrategyConfig,

libs/db/collections/models/Users.ts

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -349,19 +349,35 @@ export const Users: CollectionConfig = {
349349
type: 'collapsible',
350350
label: 'Discord',
351351
fields: [
352-
// {
353-
// name: 'discordSub',
354-
// type: 'text',
355-
// admin: {
356-
// readOnly: true,
357-
// // condition: (data, siblingData, { user }) => {
358-
// // return false
359-
// },
360-
// },
361352
{
362-
name: 'discordEmailVerified',
353+
name: 'discordUsername',
354+
type: 'text',
355+
},
356+
{
357+
name: 'discordGlobalName',
358+
type: 'text',
359+
},
360+
{
361+
name: 'discordVerified',
363362
type: 'checkbox',
364363
},
364+
{
365+
name: 'discordDiscriminator',
366+
type: 'text',
367+
},
368+
{
369+
name: 'discordLocale',
370+
type: 'text',
371+
},
372+
{
373+
name: 'discordId',
374+
type: 'text',
375+
admin: {
376+
readOnly: true,
377+
// condition: (data, siblingData, { user }) => {
378+
// return false
379+
},
380+
},
365381
],
366382
},
367383
{

libs/db/payload-types.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,12 @@ export interface User {
540540
githubPublicRepos?: string | null;
541541
githubLinkedin?: string | null;
542542
githubInstagram?: string | null;
543-
discordEmailVerified?: boolean | null;
543+
discordUsername?: string | null;
544+
discordGlobalName?: string | null;
545+
discordVerified?: boolean | null;
546+
discordDiscriminator?: string | null;
547+
discordLocale?: string | null;
548+
discordId?: string | null;
544549
googleEmail?: string | null;
545550
googleEmailVerified?: boolean | null;
546551
linkedinSub?: string | null;
@@ -1012,7 +1017,12 @@ export interface UsersSelect<T extends boolean = true> {
10121017
githubPublicRepos?: T;
10131018
githubLinkedin?: T;
10141019
githubInstagram?: T;
1015-
discordEmailVerified?: T;
1020+
discordUsername?: T;
1021+
discordGlobalName?: T;
1022+
discordVerified?: T;
1023+
discordDiscriminator?: T;
1024+
discordLocale?: T;
1025+
discordId?: T;
10161026
googleEmail?: T;
10171027
googleEmailVerified?: T;
10181028
linkedinSub?: T;

0 commit comments

Comments
 (0)