1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-02-09 00:18:00 +01:00

fix: redirect from login page if authorized

This commit is contained in:
Fredrik Oseberg 2021-04-12 15:34:37 +02:00
parent 86631b53c9
commit 8d295fd176
2 changed files with 11 additions and 4 deletions

View File

@ -50,7 +50,12 @@ const App = ({ location, user }: IAppProps) => {
<Route <Route
key={route.path} key={route.path}
path={route.path} path={route.path}
render={props => <route.component {...props} />} render={props => (
<route.component
{...props}
isUnauthorized={isUnauthorized}
/>
)}
/> />
); );
}; };

View File

@ -11,17 +11,19 @@ import { ReactComponent as UnleashLogo } from '../../../icons/unleash-logo-inver
import { ReactComponent as SwitchesSVG } from '../../../icons/switches.svg'; import { ReactComponent as SwitchesSVG } from '../../../icons/switches.svg';
import { useStyles } from './Login.styles'; import { useStyles } from './Login.styles';
const Login = ({ history, loadInitialData, authDetails }) => { const Login = ({ history, loadInitialData, isUnauthorized, authDetails }) => {
const theme = useTheme(); const theme = useTheme();
const styles = useStyles(); const styles = useStyles();
const smallScreen = useMediaQuery(theme.breakpoints.up('md')); const smallScreen = useMediaQuery(theme.breakpoints.up('md'));
useEffect(() => { useEffect(() => {
if (!authDetails) { if (isUnauthorized()) {
loadInitialData(); loadInitialData();
} else {
history.push('features');
} }
/* eslint-disable-next-line */ /* eslint-disable-next-line */
}, []); }, [authDetails]);
return ( return (
<div className={styles.loginContainer}> <div className={styles.loginContainer}>