Before finishing authentication

This commit is contained in:
2019-10-07 20:24:23 -04:00
parent 4a5c404be3
commit 8179b51844
5 changed files with 147 additions and 65 deletions

View File

@@ -1,22 +1,23 @@
import React from 'react'
import { Route, Redirect} from 'react-router-dom';
import React from 'react';
import { Route, Redirect } from 'react-router-dom';
import { connect } from 'react-redux';
import PropTypes from 'prop-types';
const AuthRoute = ({ component: Component, authenticated, ...rest }) => (
<Route
<Route
{...rest}
render={(props) =>
authenticated === true ? <Redirect to='/home'/> : <Component {...props} />}
/>
render={(props) =>
authenticated === true ? <Redirect to="/" /> : <Component {...props} />
}
/>
);
const mapStateToProps = (state) => ({
authenticated: state.user.authenticated
authenticated: state.user.authenticated
});
AuthRoute.propTypes = {
user: PropTypes.object
}
user: PropTypes.object
};
export default connect(mapStateToProps)(AuthRoute);
export default connect(mapStateToProps)(AuthRoute);