From 8d295fd176d9c7da5f8354336c6bf2431ffafc39 Mon Sep 17 00:00:00 2001 From: Fredrik Oseberg Date: Mon, 12 Apr 2021 15:34:37 +0200 Subject: [PATCH] fix: redirect from login page if authorized --- frontend/src/component/App.tsx | 7 ++++++- frontend/src/component/user/Login/Login.jsx | 8 +++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/frontend/src/component/App.tsx b/frontend/src/component/App.tsx index 5ebbc79be9..6b79a53191 100644 --- a/frontend/src/component/App.tsx +++ b/frontend/src/component/App.tsx @@ -50,7 +50,12 @@ const App = ({ location, user }: IAppProps) => { } + render={props => ( + + )} /> ); }; diff --git a/frontend/src/component/user/Login/Login.jsx b/frontend/src/component/user/Login/Login.jsx index ee9dd8c06b..c473e8c551 100644 --- a/frontend/src/component/user/Login/Login.jsx +++ b/frontend/src/component/user/Login/Login.jsx @@ -11,17 +11,19 @@ import { ReactComponent as UnleashLogo } from '../../../icons/unleash-logo-inver import { ReactComponent as SwitchesSVG } from '../../../icons/switches.svg'; import { useStyles } from './Login.styles'; -const Login = ({ history, loadInitialData, authDetails }) => { +const Login = ({ history, loadInitialData, isUnauthorized, authDetails }) => { const theme = useTheme(); const styles = useStyles(); const smallScreen = useMediaQuery(theme.breakpoints.up('md')); useEffect(() => { - if (!authDetails) { + if (isUnauthorized()) { loadInitialData(); + } else { + history.push('features'); } /* eslint-disable-next-line */ - }, []); + }, [authDetails]); return (