diff --git a/src/ForbiddenPage.js b/src/ForbiddenPage.js
new file mode 100644
index 0000000..d6877e0
--- /dev/null
+++ b/src/ForbiddenPage.js
@@ -0,0 +1,7 @@
+import React from 'react'
+
+export default ({ children, ...props }) => (
+
+ { children }
+
+)
\ No newline at end of file
diff --git a/src/PageManager.js b/src/PageManager.js
index 6d12d9f..65c1e5c 100644
--- a/src/PageManager.js
+++ b/src/PageManager.js
@@ -7,6 +7,7 @@ import { TransitionGroup, CSSTransition } from 'react-transition-group'
import Page from './Page'
import NavigationBar from './NavigationBar'
+import ForbiddenPage from './ForbiddenPage'
import './PageManager.css';
@@ -43,10 +44,17 @@ export class PageManager extends Component {
const pages = routes.filter(r => !r.props.noNavbar).map(r => ({ name: r.props.name, path: r.props.path }))
const navbars = children.filter(child => child.type === NavigationBar)
+ const forbiddenPage = children.find( c => c.type === ForbiddenPage )
+
const renderPages = (pages) => pages.map((page, i) => {
const { exact, path, ...props } = page.props
return (
- React.cloneElement(page, { ...props })} />
+ {
+ if (!this.props.authCheck || (!page.props.protected || this.props.authCheck()))
+ return React.cloneElement(page, { ...props })
+ else
+ return forbiddenPage || null
+ } } />
)
})
diff --git a/src/index.js b/src/index.js
index fa8f5bc..44326fa 100644
--- a/src/index.js
+++ b/src/index.js
@@ -1,27 +1,39 @@
-import React from 'react';
-import ReactDOM from 'react-dom';
+import React from 'react'
+import ReactDOM from 'react-dom'
-import './index.css';
+import { Redirect } from 'react-router-dom';
+
+import './index.css'
+
+import PageManager from './PageManager'
+import Page from './Page'
+import NavigationBar from './NavigationBar'
+import ForbiddenPage from './ForbiddenPage'
-import PageManager from './PageManager';
-import Page from './Page';
-import NavigationBar from './NavigationBar';
ReactDOM.render(
-
-
+ {
+ // return auth status
+ return true
+ }}
+ >
+
Splash
-
+
Home
-
+
page 2
Page 3
+
+
+