add signup, not functional authentication yet though
This commit is contained in:
parent
09654ca66b
commit
75b33a18c2
3 changed files with 15 additions and 7 deletions
|
@ -54,6 +54,7 @@
|
||||||
"react-inlinesvg": "^0.4.2",
|
"react-inlinesvg": "^0.4.2",
|
||||||
"react-redux": "^4.4.5",
|
"react-redux": "^4.4.5",
|
||||||
"redux": "^3.5.2",
|
"redux": "^3.5.2",
|
||||||
"redux-form": "^5.2.5"
|
"redux-form": "^5.2.5",
|
||||||
|
"redux-thunk": "^2.1.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,15 +6,21 @@ import axios from 'axios'
|
||||||
const ROOT_URL = location.href.indexOf('localhost') > 0 ? 'http://localhost:8000' : '/';
|
const ROOT_URL = location.href.indexOf('localhost') > 0 ? 'http://localhost:8000' : '/';
|
||||||
|
|
||||||
export function signUpUser(formValues) {
|
export function signUpUser(formValues) {
|
||||||
const request = axios.post(`${ROOT_URL}/signup`, formValues);
|
|
||||||
|
|
||||||
return function(dispatch) {
|
return function(dispatch) {
|
||||||
axios.post(`${ROOT_URL}/signup`, formValues)
|
axios.post(`${ROOT_URL}/signup`, formValues)
|
||||||
.then(response => {
|
.then(response => {
|
||||||
dispatch({ type: AUTH_USER });
|
dispatch({ type: ActionTypes.AUTH_USER });
|
||||||
localStorage.setItem('token', response.data.token);
|
localStorage.setItem('token', response.data.token);
|
||||||
browserHistory.push('/');
|
browserHistory.push('/');
|
||||||
})
|
})
|
||||||
.catch(response => dispatch(authError(response.data.error)));
|
.catch(response => dispatch(authError(response.data.error)));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export function authError(error) {
|
||||||
|
return {
|
||||||
|
type: ActionTypes.AUTH_ERROR,
|
||||||
|
payload: error
|
||||||
|
};
|
||||||
}
|
}
|
|
@ -1,11 +1,12 @@
|
||||||
import { createStore, applyMiddleware } from 'redux'
|
import { createStore, applyMiddleware, compose } from 'redux'
|
||||||
|
import thunk from 'redux-thunk'
|
||||||
import rootReducer from '../reducers'
|
import rootReducer from '../reducers'
|
||||||
|
|
||||||
export default function configureStore(initialState) {
|
export default function configureStore(initialState) {
|
||||||
const store = createStore(
|
const store = createStore(
|
||||||
rootReducer,
|
rootReducer,
|
||||||
initialState
|
initialState,
|
||||||
// applyMiddleware(thunk)
|
applyMiddleware(thunk)
|
||||||
)
|
)
|
||||||
|
|
||||||
if (module.hot) {
|
if (module.hot) {
|
||||||
|
|
Loading…
Reference in a new issue