Blame view
imports/startup/client/routes.js
2.24 KB
c42d4eeac
|
1 |
/* eslint-disable max-len */ |
2b1ad7917
|
2 3 |
import React from 'react'; import { render } from 'react-dom'; |
76dd62c7b
|
4 |
import { Router, Route, IndexRoute, browserHistory } from 'react-router'; |
cac7cbc73
|
5 |
import { Meteor } from 'meteor/meteor'; |
c42d4eeac
|
6 7 8 9 10 11 12 13 14 15 16 |
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'; |
2b1ad7917
|
17 |
|
4c9b3dfc1
|
18 |
const authenticate = (nextState, replace) => { |
cac7cbc73
|
19 |
if (!Meteor.loggingIn() && !Meteor.userId()) { |
2b1ad7917
|
20 21 |
replace({ pathname: '/login', |
cac7cbc73
|
22 |
state: { nextPathname: nextState.location.pathname }, |
2b1ad7917
|
23 24 25 |
}); } }; |
ff976df49
|
26 27 28 29 30 31 32 33 34 |
const detectOrg = () => { var hostnameArray = document.location.hostname.split( "." ); if(hostnameArray[1]=='localhost'){ orgSlug = hostnameArray[0]; }else{ orgSlug = hostnameArray[0]; } } |
2b1ad7917
|
35 |
|
f0c912bf1
|
36 |
Meteor.startup(() => { |
27ed00b55
|
37 |
|
2b1ad7917
|
38 39 40 |
render( <Router history={ browserHistory }> <Route path="/" component={ App }> |
6dc89e7c3
|
41 |
<IndexRoute name="index" component={ Index } /> |
4c9b3dfc1
|
42 43 44 45 |
<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 } /> |
7df77f0fa
|
46 47 48 49 |
<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
|
50 |
<Route path="*" component={ NotFound } /> |
2b1ad7917
|
51 52 |
</Route> </Router>, |
f0c912bf1
|
53 |
document.getElementById('react-root') |
2b1ad7917
|
54 55 |
); }); |