From b3dc044ff3cb47e21335a703b6285265e55d517c Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Wed, 29 Jun 2022 13:32:59 -0500 Subject: [PATCH] Redirect /login when a user is signed in, add /login/add for multiple accounts --- app/soapbox/components/sidebar_menu.tsx | 2 +- app/soapbox/features/auth_layout/index.tsx | 7 ++++++- app/soapbox/features/ui/components/profile-dropdown.tsx | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/soapbox/components/sidebar_menu.tsx b/app/soapbox/components/sidebar_menu.tsx index cb3962010..2940c5bfa 100644 --- a/app/soapbox/components/sidebar_menu.tsx +++ b/app/soapbox/components/sidebar_menu.tsx @@ -189,7 +189,7 @@ const SidebarMenu: React.FC = (): JSX.Element | null => {
{otherAccounts.map(account => renderAccount(account))} - + {intl.formatMessage(messages.addAccount)} diff --git a/app/soapbox/features/auth_layout/index.tsx b/app/soapbox/features/auth_layout/index.tsx index c8d10bbe6..87026e4b4 100644 --- a/app/soapbox/features/auth_layout/index.tsx +++ b/app/soapbox/features/auth_layout/index.tsx @@ -4,7 +4,7 @@ import { Link, Redirect, Route, Switch, useHistory, useLocation } from 'react-ro import LandingGradient from 'soapbox/components/landing-gradient'; import SiteLogo from 'soapbox/components/site-logo'; -import { useAppSelector, useFeatures, useSoapboxConfig } from 'soapbox/hooks'; +import { useAppSelector, useFeatures, useSoapboxConfig, useOwnAccount } from 'soapbox/hooks'; import { Button, Card, CardBody } from '../../components/ui'; import LoginPage from '../auth_login/components/login_page'; @@ -25,6 +25,7 @@ const AuthLayout = () => { 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; @@ -67,9 +68,13 @@ const AuthLayout = () => { + {/* If already logged in, redirect home. */} + {account && } + + diff --git a/app/soapbox/features/ui/components/profile-dropdown.tsx b/app/soapbox/features/ui/components/profile-dropdown.tsx index 01cef2b66..0216f3d39 100644 --- a/app/soapbox/features/ui/components/profile-dropdown.tsx +++ b/app/soapbox/features/ui/components/profile-dropdown.tsx @@ -82,7 +82,7 @@ const ProfileDropdown: React.FC = ({ account, children }) => { menu.push({ text: intl.formatMessage(messages.add), - to: '/login', + to: '/login/add', icon: require('@tabler/icons/icons/plus.svg'), });