diff --git a/.env.example b/.env.example index 0d62014..68b130f 100644 --- a/.env.example +++ b/.env.example @@ -6,6 +6,12 @@ DEV_PROXY_SERVER_PORT=3000 # used for encrypting session cookies SESSION_COOKIE_SECRET=enfix-glue-game-sermon-cinema-monarch-fog-hiccup-neighborhood-important -# oauth providers -TWITCH_CLIENT_ID= -TWITCH_CLIENT_SECRET= +# oauth providers (you must provide at least 1 pair of keys for the auth to be enabled) +# TWITCH_CLIENT_ID= +# TWITCH_CLIENT_SECRET= +# GOOGLE_CLIENT_ID= +# GOOGLE_CLIENT_SECRET= +# SPOTIFY_CLIENT_ID= +# SPOTIFY_CLIENT_SECRET= +# DISCORD_CLIENT_ID= +# DISCORD_CLIENT_SECRET= \ No newline at end of file diff --git a/client/src/components/UserAccountDemo.tsx b/client/src/components/UserAccountDemo.tsx index d670406..6e99357 100644 --- a/client/src/components/UserAccountDemo.tsx +++ b/client/src/components/UserAccountDemo.tsx @@ -8,8 +8,6 @@ import type { CSSProperties } from "react" import { definition as accountsDefinition } from "server/api/routes/accounts" export function UserAccountDemo() { - const auth = useAuthContext() - return ( <> <Divider full /> - {auth.type === "signed-in" && ( + <DynamicAuthContent /> + </> + ) +} + +const DynamicAuthContent = () => { + const auth = useAuthContext() + + if (!auth.providers.length) { + return <p>No OAuth API keys specified in the .env file, auth is disabled.</p> + } + + switch (auth.type) { + case "signed-in": + return ( <LoggedIn userId={auth.userId} signOut={auth.signOut} linkAccount={auth.linkAccount} providers={auth.providers} /> - )} - {auth.type === "creating-account" && ( + ) + case "creating-account": + return ( <CreateAccount createAccount={auth.createAccount} cancelCreateAccount={auth.cancelCreateAccount} providers={auth.providers} /> - )} - {auth.type === "unauthenticated" && ( + ) + case "unauthenticated": + return ( <NotLoggedIn submitInviteCode={auth.submitInviteCode} signIn={auth.signIn} providers={auth.providers} /> - )} - </> - ) + ) + } } function CreateAccount({