Blame view
imports/startup/client/routes.js
1.53 KB
2b1ad7917
|
1 2 |
import React from 'react'; import { render } from 'react-dom'; |
76dd62c7b
|
3 |
import { Router, Route, IndexRoute, browserHistory } from 'react-router'; |
cac7cbc73
|
4 |
import { Meteor } from 'meteor/meteor'; |
2b1ad7917
|
5 |
import { App } from '../../ui/layouts/app'; |
d1f05315d
|
6 |
import { Documents } from '../../ui/pages/documents'; |
2b1ad7917
|
7 8 |
import { Index } from '../../ui/pages/index'; import { Login } from '../../ui/pages/login'; |
c23f29749
|
9 |
import { NotFound } from '../../ui/pages/not-found'; |
2b1ad7917
|
10 11 12 |
import { RecoverPassword } from '../../ui/pages/recover-password'; import { ResetPassword } from '../../ui/pages/reset-password'; import { Signup } from '../../ui/pages/signup'; |
f0c912bf1
|
13 |
const requireAuth = (nextState, replace) => { |
cac7cbc73
|
14 |
if (!Meteor.loggingIn() && !Meteor.userId()) { |
2b1ad7917
|
15 16 |
replace({ pathname: '/login', |
cac7cbc73
|
17 |
state: { nextPathname: nextState.location.pathname }, |
2b1ad7917
|
18 19 20 |
}); } }; |
f0c912bf1
|
21 |
Meteor.startup(() => { |
2b1ad7917
|
22 23 24 |
render( <Router history={ browserHistory }> <Route path="/" component={ App }> |
7df77f0fa
|
25 |
<IndexRoute name="index" component={ Index } onEnter={ requireAuth } /> |
d1f05315d
|
26 |
<Route name="documents" path="/documents" component={ Documents } onEnter={ requireAuth } /> |
7df77f0fa
|
27 28 29 30 |
<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 } /> |
c23f29749
|
31 |
<Route path="*" component={ NotFound } /> |
2b1ad7917
|
32 33 |
</Route> </Router>, |
f0c912bf1
|
34 |
document.getElementById('react-root') |
2b1ad7917
|
35 36 |
); }); |