import ProviderIcon from '../ProviderIcon.jsx' // What the player's and the staff account pages share about a linked sign-in // identity. Steam is the one provider that differs (STEAM_SIGNIN.md): a person may // link several Steam accounts, each shows its persona name, avatar and SteamID64, // and unlinking one removes only the sign-in — a game link made from it stays // (D393). // Providers a person may link more than one account of. const MULTI_LINK = new Set(['steam']) export function canLinkAgain(providerId) { return MULTI_LINK.has(providerId) } export function identityIcon(provider) { return provider === 'google' || provider === 'discord' || provider === 'steam' ? provider : 'oidc' } // The outcome of a link round trip, from the query string it returns with. export function linkBanner(search) { const q = new URLSearchParams(search) if (q.get('linked')) return { ok: true, text: 'Account linked.' } if (q.get('link_error') === 'in_use') return { ok: false, text: 'That external account is already linked to another user on this site.' } if (q.get('link_error') === 'refused') return { ok: false, text: 'That account cannot be linked right now. Please try again later.' } if (q.get('link_error')) return { ok: false, text: 'Could not link that account. Please try again.' } return null } // Providers to offer a Link button for: every enabled one not yet linked, and a // multi-link one (Steam) always. export function linkableProviders(available, linked) { const linkedIds = new Set(linked.map((i) => i.provider)) return available.filter((p) => !linkedIds.has(p.id) || canLinkAgain(p.id)) } export function unlinkPrompt(identity, providerName) { if (identity.provider === 'steam') { const who = identity.display_name ? `${identity.display_name} (${identity.subject})` : identity.subject return `Unlink the Steam account ${who}? You will no longer be able to sign in with it. A game link made with it stays until you remove it on that game's page.` } return `Unlink ${providerName} from your account?` } // The icon (or Steam avatar), the provider name, and what identifies the account. export function IdentitySummary({ identity, providerName }) { const isSteam = identity.provider === 'steam' return ( <> {isSteam && identity.avatar_url ? ( ) : ( )}
{isSteam && identity.display_name ? `${providerName}: ${identity.display_name}` : providerName}
{isSteam && identity.subject &&
{identity.subject}
} {!isSteam && identity.email &&
{identity.email}
}
) }