2016-01-03 01:54:07 +05:30
|
|
|
import React from 'react';
|
2016-05-31 09:55:39 +05:30
|
|
|
import { Route, IndexRoute, browserHistory } from 'react-router';
|
2016-01-03 01:54:07 +05:30
|
|
|
|
2016-01-04 02:48:42 +05:30
|
|
|
import RootPage from 'pages/root/RootPage';
|
|
|
|
import IndexPage from 'pages/index/IndexPage';
|
2016-01-16 17:36:22 +05:30
|
|
|
import AuthPage from 'pages/auth/AuthPage';
|
2016-05-01 23:20:55 +05:30
|
|
|
|
2016-05-22 21:26:52 +05:30
|
|
|
import RulesPage from 'pages/rules/RulesPage';
|
|
|
|
|
2016-04-17 15:05:04 +05:30
|
|
|
import ProfilePage from 'pages/profile/ProfilePage';
|
2016-05-01 23:20:55 +05:30
|
|
|
import ProfileChangePasswordPage from 'pages/profile/ChangePasswordPage';
|
2016-05-02 18:43:18 +05:30
|
|
|
import ProfileChangeUsernamePage from 'pages/profile/ChangeUsernamePage';
|
2016-05-22 20:26:39 +05:30
|
|
|
import ProfileChangeEmailPage from 'pages/profile/ChangeEmailPage';
|
2016-01-16 17:36:22 +05:30
|
|
|
|
2016-02-23 11:27:16 +05:30
|
|
|
import OAuthInit from 'components/auth/OAuthInit';
|
2016-03-13 14:20:09 +05:30
|
|
|
import Register from 'components/auth/register/Register';
|
|
|
|
import Login from 'components/auth/login/Login';
|
|
|
|
import Permissions from 'components/auth/permissions/Permissions';
|
|
|
|
import Activation from 'components/auth/activation/Activation';
|
2016-05-23 00:28:43 +05:30
|
|
|
import ResendActivation from 'components/auth/resendActivation/ResendActivation';
|
2016-03-13 14:20:09 +05:30
|
|
|
import Password from 'components/auth/password/Password';
|
2016-03-16 11:04:18 +05:30
|
|
|
import ChangePassword from 'components/auth/changePassword/ChangePassword';
|
2016-03-13 14:20:09 +05:30
|
|
|
import ForgotPassword from 'components/auth/forgotPassword/ForgotPassword';
|
2016-05-15 02:23:58 +05:30
|
|
|
import RecoverPassword from 'components/auth/recoverPassword/RecoverPassword';
|
2016-03-15 12:06:13 +05:30
|
|
|
import Finish from 'components/auth/finish/Finish';
|
2016-01-03 01:54:07 +05:30
|
|
|
|
2016-03-02 02:06:14 +05:30
|
|
|
import authFlow from 'services/authFlow';
|
2016-01-18 10:58:43 +05:30
|
|
|
|
2016-03-02 02:06:14 +05:30
|
|
|
export default function routesFactory(store) {
|
|
|
|
authFlow.setStore(store);
|
|
|
|
|
2016-05-14 13:40:08 +05:30
|
|
|
const startAuthFlow = {
|
2016-06-02 23:16:49 +05:30
|
|
|
onEnter: ({location}, replace, callback) => authFlow.handleRequest(location.pathname, replace, callback)
|
2016-03-02 02:06:14 +05:30
|
|
|
};
|
|
|
|
|
2016-05-14 13:40:08 +05:30
|
|
|
const userOnly = {
|
|
|
|
onEnter: ({location}, replace) => {
|
|
|
|
const {user} = store.getState();
|
|
|
|
|
|
|
|
if (user.isGuest) {
|
|
|
|
replace('/');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2016-02-13 20:58:47 +05:30
|
|
|
return (
|
|
|
|
<Route path="/" component={RootPage}>
|
2016-05-14 13:40:08 +05:30
|
|
|
<IndexRoute component={IndexPage} {...startAuthFlow} />
|
|
|
|
|
2016-05-22 21:26:52 +05:30
|
|
|
<Route path="rules" component={RulesPage} />
|
|
|
|
|
2016-05-14 13:40:08 +05:30
|
|
|
<Route path="oauth" component={OAuthInit} {...startAuthFlow} />
|
|
|
|
|
2016-05-14 18:08:00 +05:30
|
|
|
<Route path="auth" component={AuthPage}>
|
|
|
|
<Route path="/login" components={new Login()} {...startAuthFlow} />
|
|
|
|
<Route path="/password" components={new Password()} {...startAuthFlow} />
|
|
|
|
<Route path="/register" components={new Register()} {...startAuthFlow} />
|
|
|
|
<Route path="/activation" components={new Activation()} {...startAuthFlow} />
|
2016-05-23 00:28:43 +05:30
|
|
|
<Route path="/resend-activation" components={new ResendActivation()} {...startAuthFlow} />
|
2016-05-14 18:08:00 +05:30
|
|
|
<Route path="/oauth/permissions" components={new Permissions()} {...startAuthFlow} />
|
|
|
|
<Route path="/oauth/finish" component={Finish} {...startAuthFlow} />
|
|
|
|
<Route path="/change-password" components={new ChangePassword()} {...startAuthFlow} />
|
|
|
|
<Route path="/forgot-password" components={new ForgotPassword()} {...startAuthFlow} />
|
2016-05-15 02:23:58 +05:30
|
|
|
<Route path="/recover-password(/:key)" components={new RecoverPassword()} {...startAuthFlow} />
|
2016-02-13 20:58:47 +05:30
|
|
|
</Route>
|
2016-04-17 15:05:04 +05:30
|
|
|
|
2016-05-14 13:40:08 +05:30
|
|
|
<Route path="profile" component={ProfilePage} {...userOnly}>
|
2016-05-01 23:20:55 +05:30
|
|
|
<Route path="change-password" component={ProfileChangePasswordPage} />
|
2016-05-02 18:43:18 +05:30
|
|
|
<Route path="change-username" component={ProfileChangeUsernamePage} />
|
2016-05-20 10:44:14 +05:30
|
|
|
<Route path="change-email(/:step)(/:code)" component={ProfileChangeEmailPage} />
|
2016-04-17 15:05:04 +05:30
|
|
|
</Route>
|
2016-02-13 20:58:47 +05:30
|
|
|
</Route>
|
|
|
|
);
|
|
|
|
}
|