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'; import Login from 'components/auth/Login'; import Permissions from 'components/auth/Permissions'; import Activation from 'components/auth/Activation'; import Password from 'components/auth/Password'; import Logout from 'components/auth/Logout'; import PasswordChange from 'components/auth/PasswordChange'; import ForgotPassword from 'components/auth/ForgotPassword'; 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 ( ); }