import React from 'react'; import { Route, IndexRoute } from 'react-router'; import RootPage from 'pages/root/RootPage'; import IndexPage from 'pages/index/IndexPage'; import AuthPage from 'pages/auth/AuthPage'; import ProfilePage from 'pages/profile/ProfilePage'; import { authenticate } from 'components/user/actions'; import OAuthInit from 'components/auth/OAuthInit'; 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'; import Password from 'components/auth/password/Password'; import ChangePassword from 'components/auth/changePassword/ChangePassword'; import ForgotPassword from 'components/auth/forgotPassword/ForgotPassword'; import Finish from 'components/auth/finish/Finish'; import ProfileChangePassword from 'components/profile/changePassword/ChangePassword'; import authFlow from 'services/authFlow'; export default function routesFactory(store) { const state = store.getState(); if (state.user.token) { // authorizing user if it is possible store.dispatch(authenticate(state.user.token)); } authFlow.setStore(store); const onEnter = { onEnter: ({location}, replace) => authFlow.handleRequest(location.pathname, replace) }; return ( ); }