add signup, not functional authentication yet though

This commit is contained in:
catarak 2016-06-09 18:41:40 -04:00
parent 09654ca66b
commit 75b33a18c2
3 changed files with 15 additions and 7 deletions

View file

@ -54,6 +54,7 @@
"react-inlinesvg": "^0.4.2",
"react-redux": "^4.4.5",
"redux": "^3.5.2",
"redux-form": "^5.2.5"
"redux-form": "^5.2.5",
"redux-thunk": "^2.1.0"
}
}

View file

@ -6,15 +6,21 @@ import axios from 'axios'
const ROOT_URL = location.href.indexOf('localhost') > 0 ? 'http://localhost:8000' : '/';
export function signUpUser(formValues) {
const request = axios.post(`${ROOT_URL}/signup`, formValues);
return function(dispatch) {
axios.post(`${ROOT_URL}/signup`, formValues)
.then(response => {
dispatch({ type: AUTH_USER });
dispatch({ type: ActionTypes.AUTH_USER });
localStorage.setItem('token', response.data.token);
browserHistory.push('/');
})
.catch(response => dispatch(authError(response.data.error)));
}
}
export function authError(error) {
return {
type: ActionTypes.AUTH_ERROR,
payload: error
};
}

View file

@ -1,11 +1,12 @@
import { createStore, applyMiddleware } from 'redux'
import { createStore, applyMiddleware, compose } from 'redux'
import thunk from 'redux-thunk'
import rootReducer from '../reducers'
export default function configureStore(initialState) {
const store = createStore(
rootReducer,
initialState
// applyMiddleware(thunk)
initialState,
applyMiddleware(thunk)
)
if (module.hot) {