import React from 'react'; import { defineMessages, useIntl } from 'react-intl'; import { Link, Redirect, Route, Switch, useHistory, useLocation } from 'react-router-dom'; import LandingGradient from 'soapbox/components/landing-gradient'; import SiteLogo from 'soapbox/components/site-logo'; import { useAppSelector, useFeatures, useSoapboxConfig, useOwnAccount } from 'soapbox/hooks'; import { Button, Card, CardBody } from '../../components/ui'; import LoginPage from '../auth_login/components/login_page'; import PasswordReset from '../auth_login/components/password_reset'; import PasswordResetConfirm from '../auth_login/components/password_reset_confirm'; import RegistrationForm from '../auth_login/components/registration_form'; import ExternalLoginForm from '../external_login/components/external-login-form'; import Footer from '../public_layout/components/footer'; import RegisterInvite from '../register_invite'; import Verification from '../verification'; import EmailPassthru from '../verification/email_passthru'; const messages = defineMessages({ register: { id: 'auth_layout.register', defaultMessage: 'Create an account' }, }); const AuthLayout = () => { const intl = useIntl(); const history = useHistory(); const { search } = useLocation(); const account = useOwnAccount(); const siteTitle = useAppSelector(state => state.instance.title); const soapboxConfig = useSoapboxConfig(); const pepeEnabled = soapboxConfig.getIn(['extensions', 'pepe', 'enabled']) === true; const features = useFeatures(); const instance = useAppSelector((state) => state.instance); const isOpen = features.accountCreation && instance.registrations; const pepeOpen = useAppSelector(state => state.verification.instance.get('registrations') === true); const isLoginPage = history.location.pathname === '/login'; const shouldShowRegisterLink = (isLoginPage && (isOpen || (pepeEnabled && pepeOpen))); return (
{shouldShowRegisterLink && (
)}
{/* If already logged in, redirect home. */} {account && }
); }; export default AuthLayout;