mirror of https://gitlab.com/ecentrics/concordia
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
566 B
25 lines
566 B
import React from 'react';
|
|
import { drizzleConnect } from 'drizzle-react';
|
|
import { Route } from "react-router";
|
|
import { Redirect } from "react-router-dom";
|
|
|
|
const PrivateRoute = (props) => {
|
|
return (
|
|
props.user.hasSignedUp
|
|
? <Route path={props.path} component={props.component} />
|
|
: <Redirect
|
|
from={props.path}
|
|
to="/login"
|
|
/>
|
|
);
|
|
};
|
|
|
|
const mapStateToProps = state => {
|
|
return {
|
|
user: state.user
|
|
}
|
|
};
|
|
|
|
const PrivateRouteContainer = drizzleConnect(PrivateRoute, mapStateToProps);
|
|
|
|
export default PrivateRouteContainer;
|