From bbb64c41118f70e808ff02b20e3403a5037fde86 Mon Sep 17 00:00:00 2001 From: Asara Date: Mon, 16 Sep 2019 20:53:34 -0400 Subject: [PATCH] Flesh out the state wiring for auth --- src/actions/index.js | 1 + src/components/AuthMenu.js | 13 ++++++++++--- src/reducers/authReducer.js | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/actions/index.js b/src/actions/index.js index d894f68..3f41943 100644 --- a/src/actions/index.js +++ b/src/actions/index.js @@ -24,4 +24,5 @@ export const userLogin = (username, password) => async (dispatch) => { password: password }) dispatch({ type: 'USER_LOGIN', payload: response }) + return(response) }; diff --git a/src/components/AuthMenu.js b/src/components/AuthMenu.js index 2443454..95f2b73 100644 --- a/src/components/AuthMenu.js +++ b/src/components/AuthMenu.js @@ -63,9 +63,16 @@ class AuthMenu extends Component { handleLogin() { this.props.userLogin(this.state.username, this.state.password) - this.setState(state => ({ - auth_menu_visible: false, - })); + .then(res => { + this.setState(state => ({ + auth_menu_visible: false + })) + console.log(res) + } + ) + .catch(err => { + console.log(err); + }) } handleCreateAccount() { diff --git a/src/reducers/authReducer.js b/src/reducers/authReducer.js index 9962663..c6b6b38 100644 --- a/src/reducers/authReducer.js +++ b/src/reducers/authReducer.js @@ -7,7 +7,7 @@ const initialState = { export default (state = initialState, action) => { switch (action.type) { case 'USER_LOGIN': - return {jwt: action.payload} + return {...state, ...{jwt: action.payload}} default: return state; }