Skip to content

Commit 24ab052

Browse files
authored
fix(social-login): add Discord OAuth login button (#65)
is_discord_login_enabled was never wired into AuthorizerSocialLogin, so operators with Discord enabled on the backend had no button to trigger /oauth_login/discord. Mirrors the existing Twitch/Roblox pattern: new icon, config flag, hasSocialLogin check, button block. Closes #64
1 parent 6776df5 commit 24ab052

4 files changed

Lines changed: 46 additions & 1 deletion

File tree

src/components/AuthorizerSocialLogin.tsx

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { Twitter } from '../icons/twitter';
1313
import { Microsoft } from '../icons/microsoft';
1414
import { Twitch } from '../icons/twitch';
1515
import { Roblox } from '../icons/roblox';
16+
import { Discord } from '../icons/discord';
1617

1718
export const AuthorizerSocialLogin: FC<{
1819
urlProps?: Record<string, any>;
@@ -28,7 +29,8 @@ export const AuthorizerSocialLogin: FC<{
2829
config.is_twitter_login_enabled ||
2930
config.is_microsoft_login_enabled ||
3031
config.is_twitch_login_enabled ||
31-
config.is_roblox_login_enabled;
32+
config.is_roblox_login_enabled ||
33+
config.is_discord_login_enabled;
3234
// AuthorizerPasskeyLogin always renders immediately after this component
3335
// (AuthorizerRoot, web/app's login.tsx) and owns its own "OR" separator
3436
// for whatever follows it - suppress this one so the two don't stack.
@@ -182,6 +184,20 @@ export const AuthorizerSocialLogin: FC<{
182184
<br />
183185
</>
184186
)}
187+
{config.is_discord_login_enabled && (
188+
<>
189+
<StyledButton
190+
appearance={ButtonAppearance.Default}
191+
onClick={() => {
192+
window.location.href = `${config.authorizerURL}/oauth_login/discord?${queryParams}`;
193+
}}
194+
>
195+
<Discord />
196+
Continue with Discord
197+
</StyledButton>
198+
<br />
199+
</>
200+
)}
185201
{hasSocialLogin &&
186202
!willShowPasskey &&
187203
(config.is_basic_authentication_enabled ||

src/contexts/AuthorizerContext.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ const AuthorizerContext = createContext<AuthorizerContextPropsType>({
3131
is_microsoft_login_enabled: false,
3232
is_twitch_login_enabled: false,
3333
is_roblox_login_enabled: false,
34+
is_discord_login_enabled: false,
3435
is_email_verification_enabled: false,
3536
is_basic_authentication_enabled: false,
3637
is_magic_link_login_enabled: false,
@@ -111,6 +112,7 @@ let initialState: AuthorizerState = {
111112
is_microsoft_login_enabled: false,
112113
is_twitch_login_enabled: false,
113114
is_roblox_login_enabled: false,
115+
is_discord_login_enabled: false,
114116
is_email_verification_enabled: false,
115117
is_basic_authentication_enabled: false,
116118
is_magic_link_login_enabled: false,

src/icons/discord.tsx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
export const Discord = () => {
3+
return (
4+
<div
5+
style={{
6+
position: 'absolute',
7+
left: '10px',
8+
top: '12px',
9+
display: 'flex',
10+
}}
11+
>
12+
<svg
13+
xmlns="http://www.w3.org/2000/svg"
14+
height="24"
15+
width="24"
16+
viewBox="0 0 33 32"
17+
>
18+
<path
19+
fill="#5865F2"
20+
d="M27.5928 6.20817C25.5533 5.27289 23.3662 4.58382 21.0794 4.18916C21.0378 4.18154 20.9962 4.20057 20.9747 4.23864C20.6935 4.73863 20.3819 5.3909 20.1637 5.90358C17.7042 5.53558 15.2573 5.53558 12.8481 5.90358C12.6299 5.37951 12.307 4.73863 12.0245 4.23864C12.003 4.20184 11.9614 4.18281 11.9198 4.18916C9.63431 4.58255 7.44721 5.27163 5.40641 6.20817C5.38874 6.21578 5.3736 6.22848 5.36355 6.24497C1.21508 12.439 0.078646 18.4809 0.636144 24.4478C0.638667 24.477 0.655064 24.5049 0.677768 24.5227C3.41481 26.5315 6.06609 27.7511 8.66815 28.5594C8.70979 28.5721 8.75392 28.5569 8.78042 28.5226C9.39594 27.6826 9.94461 26.7968 10.4151 25.8653C10.4428 25.8107 10.4163 25.746 10.3596 25.7244C9.48927 25.3945 8.66058 24.9922 7.86343 24.5354C7.80038 24.4986 7.79533 24.4084 7.85333 24.3653C8.02108 24.2397 8.18888 24.109 8.34906 23.977C8.37804 23.9529 8.41842 23.9478 8.45249 23.963C13.6894 26.3526 19.359 26.3526 24.5341 23.963C24.5682 23.9465 24.6086 23.9516 24.6388 23.9757C24.799 24.1077 24.9668 24.2397 25.1358 24.3653C25.1938 24.4084 25.19 24.4986 25.127 24.5354C24.3298 25.0011 23.5011 25.3945 22.6296 25.7232C22.5728 25.7447 22.5476 25.8107 22.5754 25.8653C23.0559 26.7955 23.6046 27.6812 24.2087 28.5213C24.234 28.5569 24.2794 28.5721 24.321 28.5594C26.9357 27.7511 29.5869 26.5315 32.324 24.5227C32.348 24.5049 32.3631 24.4783 32.3656 24.4491C33.0328 17.5506 31.2481 11.5584 27.6344 6.24623C27.6256 6.22848 27.6105 6.21578 27.5928 6.20817ZM11.1971 20.8146C9.62043 20.8146 8.32129 19.3679 8.32129 17.5913C8.32129 15.8146 9.59523 14.368 11.1971 14.368C12.8115 14.368 14.0981 15.8273 14.0729 17.5913C14.0729 19.3679 12.7989 20.8146 11.1971 20.8146ZM21.8299 20.8146C20.2533 20.8146 18.9541 19.3679 18.9541 17.5913C18.9541 15.8146 20.228 14.368 21.8299 14.368C23.4444 14.368 24.7309 15.8273 24.7057 17.5913C24.7057 19.3679 23.4444 20.8146 21.8299 20.8146Z"
21+
/>
22+
</svg>
23+
</div>
24+
);
25+
};

src/types/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export type AuthorizerConfig = {
1414
is_microsoft_login_enabled: boolean;
1515
is_twitch_login_enabled: boolean;
1616
is_roblox_login_enabled: boolean;
17+
is_discord_login_enabled: boolean;
1718
is_email_verification_enabled: boolean;
1819
is_basic_authentication_enabled: boolean;
1920
is_magic_link_login_enabled: boolean;
@@ -56,6 +57,7 @@ export type AuthorizerContextPropsType = {
5657
is_microsoft_login_enabled: boolean;
5758
is_twitch_login_enabled: boolean;
5859
is_roblox_login_enabled: boolean;
60+
is_discord_login_enabled: boolean;
5961
is_email_verification_enabled: boolean;
6062
is_basic_authentication_enabled: boolean;
6163
is_magic_link_login_enabled: boolean;

0 commit comments

Comments
 (0)