21 lines
525 B
JavaScript
21 lines
525 B
JavaScript
import React, { PropTypes } from 'react'
|
|
|
|
import defaultPage from './defaultPage'
|
|
|
|
const securePageHoc = Page => class SecurePage extends React.Component {
|
|
static getInitialProps (ctx) {
|
|
return Page.getInitialProps && Page.getInitialProps(ctx)
|
|
}
|
|
static propTypes = {
|
|
isAuthenticated: PropTypes.bool.isRequired
|
|
}
|
|
render () {
|
|
if (!this.props.isAuthenticated) {
|
|
return (<p>Unauthroized</p>);
|
|
}
|
|
return (<Page {...this.props} />);
|
|
}
|
|
}
|
|
|
|
export default Page => defaultPage(securePageHoc(Page))
|