From f862489fe85a93937e6a0ec120917816e256f2bf Mon Sep 17 00:00:00 2001 From: olav Date: Wed, 16 Feb 2022 09:36:00 +0100 Subject: [PATCH] refactor: fix login redirect for users without permissions (#714) --- frontend/src/component/user/Login/Login.tsx | 23 ++++++++------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/frontend/src/component/user/Login/Login.tsx b/frontend/src/component/user/Login/Login.tsx index 33869d1e43..4e7f266710 100644 --- a/frontend/src/component/user/Login/Login.tsx +++ b/frontend/src/component/user/Login/Login.tsx @@ -1,30 +1,25 @@ -import { useEffect } from 'react'; import ConditionallyRender from '../../common/ConditionallyRender'; import { useStyles } from './Login.styles'; import useQueryParams from '../../../hooks/useQueryParams'; import ResetPasswordSuccess from '../common/ResetPasswordSuccess/ResetPasswordSuccess'; import StandaloneLayout from '../common/StandaloneLayout/StandaloneLayout'; import { DEMO_TYPE } from '../../../constants/authTypes'; -import { useHistory } from 'react-router'; -import Authentication from "../Authentication/Authentication"; +import Authentication from '../Authentication/Authentication'; import { useAuthDetails } from '../../../hooks/api/getters/useAuth/useAuthDetails'; -import { useAuthPermissions } from '../../../hooks/api/getters/useAuth/useAuthPermissions'; +import { useAuthUser } from '../../../hooks/api/getters/useAuth/useAuthUser'; +import { Redirect } from 'react-router-dom'; const Login = () => { const styles = useStyles(); const { authDetails } = useAuthDetails(); - const { permissions } = useAuthPermissions(); + const { user } = useAuthUser(); const query = useQueryParams(); - const history = useHistory(); - - useEffect(() => { - if (permissions?.length) { - history.push('features'); - } - /* eslint-disable-next-line */ - }, [permissions?.length]); - const resetPassword = query.get('reset') === 'true'; + + if (user) { + return ; + } + return (