{"size": 431, "ext": "js", "max_stars_repo_path": "src/components/with_auth.js", "max_stars_repo_name": "bengladwell/inside-story", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/components/with_auth.js", "max_issues_repo_name": "bengladwell/inside-story", "max_issues_repo_issues_event_min_datetime": "2021-09-21T17:14:29.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-27T11:34:25.000Z", "max_forks_repo_path": "src/components/with_auth.js", "max_forks_repo_name": "bengladwell/inside-story", "max_forks_repo_forks_event_min_datetime": "2021-12-08T18:16:06.000Z", "max_forks_repo_forks_event_max_datetime": "2021-12-08T18:16:06.000Z"}
{"max_stars_count": null, "max_issues_count": 16, "max_forks_count": 1, "avg_line_length": 22.6842105263, "max_line_length": 84, "alphanum_fraction": 0.6914153132}
import React from 'react'
import PropTypes from 'prop-types'
import { userContext } from '../context'
import UnauthMessage from './unauth_message'

const WithAuth = ({ children }) => {
  return (
    <userContext.Consumer>
      { user => user && user.authorized ? children : <UnauthMessage user={user} /> }
    </userContext.Consumer>
  )
}

WithAuth.propTypes = {
  children: PropTypes.node.isRequired
}

export default WithAuth
