diff --git a/js-frontend/gulpfile.babel.js b/js-frontend/gulpfile.babel.js index 15f1e53..7495944 100644 --- a/js-frontend/gulpfile.babel.js +++ b/js-frontend/gulpfile.babel.js @@ -14,7 +14,7 @@ const PORT = process.env.PORT || 3000; const $ = gulpLoadPlugins({camelize: true}); -// Main tasks +// MyAccounts tasks gulp.task('serve', () => runSequence('serve:clean', 'serve:index', 'serve:start')); gulp.task('dist', () => runSequence('dist:clean', 'dist:build', 'dist:index')); gulp.task('clean', ['dist:clean', 'serve:clean']); diff --git a/js-frontend/src/App.js b/js-frontend/src/App.js index 044c391..50e5c7c 100644 --- a/js-frontend/src/App.js +++ b/js-frontend/src/App.js @@ -3,22 +3,23 @@ */ import React from "react"; +import { createStore, compose, applyMiddleware, combineReducers} from "redux"; import { Provider} from "react-redux"; +import thunk from "redux-thunk"; + +import { Route, IndexRoute, Link, IndexLink } from "react-router"; import { ReduxRouter} from "redux-router"; + //import { Router, IndexRoute, Route, browserHistory } from 'react-router'; //import { syncHistory, routeReducer } from 'react-router-redux'; -import { Route, IndexRoute, Link, IndexLink} from "react-router"; -import { configure as reduxAuthConfigure, authStateReducer} from "redux-auth"; +import { configure as reduxAuthConfigure, authStateReducer } from "redux-auth"; import { AuthGlobals } from "redux-auth/bootstrap-theme"; -import { createStore, compose, applyMiddleware} from "redux"; import { createHistory, createHashHistory, createMemoryHistory } from "history"; import { routerStateReducer, reduxReactRouter as clientRouter} from "redux-router"; import { reduxReactRouter as serverRouter } from "redux-router/server"; -import { combineReducers} from "redux"; -import thunk from "redux-thunk"; import { connect } from 'react-redux'; import { pushState } from 'redux-router'; @@ -26,7 +27,7 @@ import { pushState } from 'redux-router'; //import demoButtons from "./reducers/request-test-buttons"; //import demoUi from "./reducers/demo-ui"; import Container from "./components/partials/Container"; -import Main from "./views/Main"; +import MyAccounts from "./views/MyAccounts"; import Account from "./views/Account"; import SignIn from "./views/SignIn"; import SignUp from "./views/SignUp"; @@ -71,6 +72,18 @@ export function initialize({cookies, isServer, currentLocation, userAgent} = {}) // }, 0); //}; + const requireAuth = next => + (nextState, transition, cb) => { + debugger; + if (!auth.isLoggedIn()) { + transition.to('/login', null, {redirect: nextState.location}); + return; + } + next(nextState, transition); + }; + + const mw = compose(requireAuth); + const requireAuthentication = (Component) => { class AuthenticatedComponent extends React.Component { @@ -115,24 +128,22 @@ export function initialize({cookies, isServer, currentLocation, userAgent} = {}) // define app routes // + // const routes = ( - + + + - + ); // these methods will differ from server to client - var reduxReactRouter = clientRouter; - var createHistoryMethod = createHashHistory; - - if (isServer) { - reduxReactRouter = serverRouter; - createHistoryMethod = createMemoryHistory; - } + const reduxReactRouter = isServer ? serverRouter : clientRouter; + const createHistoryMethod = isServer ? createMemoryHistory : createHashHistory; // create the redux store const store = compose( @@ -192,7 +203,7 @@ export function initialize({cookies, isServer, currentLocation, userAgent} = {}) return