Created
December 8, 2016 14:10
-
-
Save acomito/9d26ff708774b52a86911fe65d9022c9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { render } from 'react-dom'; | |
import { Router, Route, IndexRoute, browserHistory } from 'react-router'; | |
import { Meteor } from 'meteor/meteor'; | |
import App from '../../ui/layouts/App.js'; | |
import Documents from '../../ui/pages/Documents.js'; | |
import NewDocument from '../../ui/pages/NewDocument.js'; | |
import EditDocument from '../../ui/containers/EditDocument.js'; | |
import ViewDocument from '../../ui/containers/ViewDocument.js'; | |
import Index from '../../ui/pages/Index.js'; | |
import Login from '../../ui/pages/Login.js'; | |
import NotFound from '../../ui/pages/NotFound.js'; | |
import RecoverPassword from '../../ui/pages/RecoverPassword.js'; | |
import ResetPassword from '../../ui/pages/ResetPassword.js'; | |
import Signup from '../../ui/pages/Signup.js'; | |
const authenticate = (nextState, replace) => { | |
if (!Meteor.loggingIn() && !Meteor.userId()) { | |
replace({ | |
pathname: '/login', | |
state: { nextPathname: nextState.location.pathname }, | |
}); | |
} | |
}; | |
Meteor.startup(() => { | |
render( | |
<Router history={ browserHistory }> | |
<Route path="/" component={ App }> | |
<IndexRoute name="index" component={ Index } /> {/* we removed the onEnter from this line */} | |
<Route name="documents" path="/documents" component={ Documents } onEnter={ authenticate } /> | |
<Route name="newDocument" path="/documents/new" component={ NewDocument } onEnter={ authenticate } /> | |
<Route name="editDocument" path="/documents/:_id/edit" component={ EditDocument } onEnter={ authenticate } /> | |
<Route name="viewDocument" path="/documents/:_id" component={ ViewDocument } onEnter={ authenticate } /> | |
<Route name="login" path="/login" component={ Login } /> | |
<Route name="recover-password" path="/recover-password" component={ RecoverPassword } /> | |
<Route name="reset-password" path="/reset-password/:token" component={ ResetPassword } /> | |
<Route name="signup" path="/signup" component={ Signup } /> | |
<Route path="*" component={ NotFound } /> | |
</Route> | |
</Router>, | |
document.getElementById('react-root') | |
); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment