diff --git a/src/actions/index.js b/src/actions/index.js index d894f68..0959fec 100644 --- a/src/actions/index.js +++ b/src/actions/index.js @@ -23,5 +23,10 @@ export const userLogin = (username, password) => async (dispatch) => { username: username, password: password }) - dispatch({ type: 'USER_LOGIN', payload: response }) + if (response.status === 401) { + alert("Please check your credentials") + } + if (response.status === 200) { + dispatch({ type: 'USER_LOGIN', payload: response }) + } }; diff --git a/src/components/AuthMenu.js b/src/components/AuthMenu.js index 95f2b73..9ef009c 100644 --- a/src/components/AuthMenu.js +++ b/src/components/AuthMenu.js @@ -67,7 +67,7 @@ class AuthMenu extends Component { this.setState(state => ({ auth_menu_visible: false })) - console.log(res) + this.props.close() } ) .catch(err => { diff --git a/src/components/NavBar.js b/src/components/NavBar.js index ecc3f8e..cc0e320 100644 --- a/src/components/NavBar.js +++ b/src/components/NavBar.js @@ -29,7 +29,7 @@ class NavBar extends Component {
Login - + this.setState({auth_menu_visible: false})}>
diff --git a/src/reducers/authReducer.js b/src/reducers/authReducer.js index 164f00d..c24d51b 100644 --- a/src/reducers/authReducer.js +++ b/src/reducers/authReducer.js @@ -9,6 +9,7 @@ export default (state = initialState, action) => { case 'USER_LOGIN': return {...state, ...{ jwt: action.payload.data.jwt, + username: action.payload.data.username, user_logged_in: true }} default: