Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

3.5 KB
Raw Blame
import { SSO_PROVIDER_NAMES } from 'lib/constants'
import { Link } from 'lib/lemon-ui/Link'

import { SSOProvider } from '~/types'

// Login error copy shared by the auth login variants and the exporter login screen.
export const ERROR_MESSAGES: Record<string, string | JSX.Element> = {
    no_new_organizations:
        'Your email address is not associated with an account. Please ask your administrator for an invite.',
    invalid_sso_provider: (
        <>
            The SSO provider you specified is invalid. Visit{' '}
            <Link to="https://posthog.com/sso" target="_blank">
                https://posthog.com/sso
            </Link>{' '}
            for details.
        </>
    ),
    improperly_configured_sso: (
        <>
            Cannot login with SSO provider because the provider is not configured, or your instance does not have the
            required license. Please visit{' '}
            <Link to="https://posthog.com/sso" target="_blank">
                https://posthog.com/sso
            </Link>{' '}
            for details.
        </>
    ),
    jit_not_enabled:
        'We could not find an account with your email address and your organization does not support automatic enrollment. Please contact your administrator for an invite.',
    saml_sso_enforced:
        'Your organization requires SAML SSO authentication. Please enter your email address to access your account.',
    google_sso_enforced: 'Your organization does not allow this authentication method. Please log in with Google.',
    github_sso_enforced: 'Your organization does not allow this authentication method. Please log in with GitHub.',
    gitlab_sso_enforced: 'Your organization does not allow this authentication method. Please log in with GitLab.',
    // our catch-all case, so the message is generic
    sso_enforced: "Please log in with your organization's required SSO method.",
    verified_domain_required:
        "Your organization only allows members with a verified email domain. Contact your organization's admin for access.",
    oauth_cancelled: "Sign in was cancelled. Please try again when you're ready.",
    reauth_user_mismatch:
        "You signed in with a different account. Please try again with the account you're logged in as.",
    invalid_invite:
        'This invite link is no longer valid. It may have expired or been revoked. Please ask your administrator for a new invite.',
    invite_email_mismatch:
        'This invite was sent to a different email address. Log in with that address, or ask your administrator for a new invite.',
    invite_already_member: "You're already a member of this organization. Log in to continue.",
    invite_email_taken:
        'An account with this email address already belongs to this organization. Log in with that account to continue.',
    social_login_failure: 'Login failed. Please try again or contact your administrator.',
    access_blocked:
        "We couldn't sign you in. If you think this is a mistake, contact support and quote the code access_blocked.",
}

// The server detail for `sso_enforced` holds the internal provider key, so the login form uses this copy instead
export function ssoEnforcedMessage(provider: SSOProvider | string | null | undefined): string {
    const providerName = provider ? SSO_PROVIDER_NAMES[provider as SSOProvider] : undefined
    return providerName
        ? `Your organization requires you to log in with ${providerName}.`
        : "Please log in with your organization's required SSO method."
}