import React, { Component } from 'react' import { connect } from 'react-redux' import './auth.css' import actions from 'app/actions' import AuthLogin from './auth.login' class AuthGate extends Component { constructor(props) { super(props) actions.auth.load_access_token() } componentDidUpdate(prevProps) { if (this.props.user.id !== prevProps.user.id) { this.load() } } load() { if (!this.props.user.id) return actions.site.loadProject() } render() { if (this.props.logged_in) { return this.props.children } return (
) } } const mapStateToProps = state => ({ ...state.auth, }) export default connect(mapStateToProps)(AuthGate)