1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-22 19:07:54 +01:00

refactor: fix login redirect for users without permissions (#714)

This commit is contained in:
olav 2022-02-16 09:36:00 +01:00 committed by GitHub
parent c76ed5ce95
commit f862489fe8

View File

@ -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 <Redirect to="/features" />;
}
return (
<StandaloneLayout>
<div className={styles.loginFormContainer}>