Store auth info in a JWT token in a cookie

This commit is contained in:
Ken-Håvard Lieng 2016-01-15 02:27:30 +01:00
parent 3e0a1be6bc
commit fb54d4966c
18 changed files with 499 additions and 331 deletions

View file

@ -1,35 +1,22 @@
import React from 'react';
import { render } from 'react-dom';
import { syncReduxAndRouter, replacePath } from 'redux-simple-router';
import { syncReduxAndRouter } from 'redux-simple-router';
import createBrowserHistory from 'history/lib/createBrowserHistory';
import configureStore from './store';
import createRoutes from './routes';
import Socket from './util/Socket';
import handleSocket from './socket';
import { createUUID } from './util';
import Root from './containers/Root';
const host = __DEV__ ? `${window.location.hostname}:1337` : window.location.host;
let uuid = localStorage.uuid;
let newUser = false;
if (!uuid) {
uuid = createUUID();
newUser = true;
}
const socket = new Socket(host, uuid);
const socket = new Socket(host);
const store = configureStore(socket);
handleSocket(socket, store);
const history = createBrowserHistory();
syncReduxAndRouter(history, store);
if (newUser) {
store.dispatch(replacePath('/connect'));
localStorage.uuid = uuid;
}
const routes = createRoutes();
render(<Root store={store} routes={routes} history={history} />, document.getElementById('root'));