mirror of
https://github.com/ClaytonWWilson/CS307-Team24.git
synced 2026-03-10 21:25:04 +00:00
Before finishing authentication
This commit is contained in:
@@ -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);
|
||||
Reference in New Issue
Block a user