Redirect all /auth routes

This commit is contained in:
Alex Gleason 2022-04-19 14:37:48 -05:00
parent 55c4e3a00b
commit 5731b9b1c7
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7
14 changed files with 31 additions and 3 deletions

Binary file not shown.

Binary file not shown.

View file

@ -285,7 +285,7 @@ const SidebarMenu: React.FC = (): JSX.Element | null => {
<hr /> <hr />
<SidebarLink <SidebarLink
to='/auth/sign_out' to='/logout'
icon={require('@tabler/icons/icons/logout.svg')} icon={require('@tabler/icons/icons/logout.svg')}
text={intl.formatMessage(messages.logout)} text={intl.formatMessage(messages.logout)}
onClick={onClickLogOut} onClick={onClickLogOut}

Binary file not shown.

View file

@ -0,0 +1,28 @@
import React, { useEffect, useState } from 'react';
import { useIntl } from 'react-intl';
import { useDispatch } from 'react-redux';
import { Redirect } from 'react-router-dom';
import { logOut } from 'soapbox/actions/auth';
import { Spinner } from 'soapbox/components/ui';
/** Component that logs the user out when rendered */
const Logout: React.FC = () => {
const intl = useIntl();
const dispatch = useDispatch();
const [done, setDone] = useState(false);
useEffect(() => {
(dispatch(logOut(intl)) as any)
.then(() => setDone(true))
.catch(console.warn);
});
if (done) {
return <Redirect to='/' />;
} else {
return <Spinner />;
}
};
export default Logout;

View file

@ -59,7 +59,7 @@ const LinkFooter: React.FC = (): JSX.Element => {
{(features.federating && features.accountMoving) && ( {(features.federating && features.accountMoving) && (
<FooterLink to='/settings/migration'><FormattedMessage id='navigation_bar.account_migration' defaultMessage='Move account' /></FooterLink> <FooterLink to='/settings/migration'><FormattedMessage id='navigation_bar.account_migration' defaultMessage='Move account' /></FooterLink>
)} )}
<FooterLink to='/auth/sign_out' onClick={onClickLogOut}><FormattedMessage id='navigation_bar.logout' defaultMessage='Logout' /></FooterLink> <FooterLink to='/logout' onClick={onClickLogOut}><FormattedMessage id='navigation_bar.logout' defaultMessage='Logout' /></FooterLink>
</>} </>}
</div> </div>

View file

@ -87,7 +87,7 @@ const ProfileDropdown: React.FC<IProfileDropdown> = ({ account, children }) => {
menu.push({ menu.push({
text: intl.formatMessage(messages.logout, { acct: account.acct }), text: intl.formatMessage(messages.logout, { acct: account.acct }),
to: '/auth/sign_out', to: '/logout',
action: handleLogOut, action: handleLogOut,
icon: require('@tabler/icons/icons/logout.svg'), icon: require('@tabler/icons/icons/logout.svg'),
}); });

Binary file not shown.