mirror of
https://github.com/Unleash/unleash.git
synced 2024-12-22 19:07:54 +01:00
fix: update PR based on feedback
This commit is contained in:
parent
a47d53d0f4
commit
1796aeb3ea
@ -87,6 +87,7 @@ export const App = () => {
|
||||
path="/"
|
||||
unauthorized={isUnauthorized()}
|
||||
component={Redirect}
|
||||
renderProps={{ to: '/features' }}
|
||||
/>
|
||||
{renderMainLayoutRoutes()}
|
||||
{renderStandaloneRoutes()}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Route, useLocation, useHistory } from 'react-router-dom';
|
||||
import { Route, useLocation, Redirect } from 'react-router-dom';
|
||||
|
||||
const ProtectedRoute = ({
|
||||
component: Component,
|
||||
@ -7,7 +7,6 @@ const ProtectedRoute = ({
|
||||
...rest
|
||||
}) => {
|
||||
const { pathname } = useLocation();
|
||||
const history = useHistory();
|
||||
const loginLink =
|
||||
pathname.length > 1 ? `/login?redirect=${pathname}` : '/login';
|
||||
return (
|
||||
@ -15,7 +14,7 @@ const ProtectedRoute = ({
|
||||
{...rest}
|
||||
render={props => {
|
||||
if (unauthorized) {
|
||||
history.push(loginLink);
|
||||
return <Redirect to={loginLink} />;
|
||||
} else {
|
||||
return <Component {...props} {...renderProps} />;
|
||||
}
|
||||
|
@ -90,6 +90,7 @@ const DemoAuth = ({ authDetails, redirect }) => {
|
||||
|
||||
DemoAuth.propTypes = {
|
||||
authDetails: PropTypes.object.isRequired,
|
||||
redirect: PropTypes.string.isRequired,
|
||||
};
|
||||
|
||||
export default DemoAuth;
|
||||
|
@ -7,7 +7,7 @@ import { DEMO_TYPE } from '../../../constants/authTypes';
|
||||
import Authentication from '../Authentication/Authentication';
|
||||
import { useAuthDetails } from '../../../hooks/api/getters/useAuth/useAuthDetails';
|
||||
import { useAuthUser } from '../../../hooks/api/getters/useAuth/useAuthUser';
|
||||
import { useHistory } from 'react-router-dom';
|
||||
import { Redirect, useHistory } from 'react-router-dom';
|
||||
|
||||
const Login = () => {
|
||||
const styles = useStyles();
|
||||
@ -15,11 +15,10 @@ const Login = () => {
|
||||
const { user } = useAuthUser();
|
||||
const query = useQueryParams();
|
||||
const resetPassword = query.get('reset') === 'true';
|
||||
const redirect = query.get('redirect') || '/features';
|
||||
const history = useHistory();
|
||||
const redirect = query.get('redirect') || '/';
|
||||
|
||||
if (user) {
|
||||
history.replace(redirect);
|
||||
return <Redirect to={redirect} />;
|
||||
}
|
||||
|
||||
return (
|
||||
|
Loading…
Reference in New Issue
Block a user