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 { 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 Logout from 'components/auth/Logout'; import PasswordChange from 'components/auth/passwordChange/PasswordChange'; import ForgotPassword from 'components/auth/forgotPassword/ForgotPassword'; import Finish from 'components/auth/Finish'; 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 ( ); }