1
0
Fork 0

Flesh out the state wiring for auth

This commit is contained in:
Amarpreet Minhas 2019-09-16 20:53:34 -04:00
parent 251c3fc25d
commit bbb64c4111
3 changed files with 12 additions and 4 deletions

View file

@ -24,4 +24,5 @@ export const userLogin = (username, password) => async (dispatch) => {
password: password password: password
}) })
dispatch({ type: 'USER_LOGIN', payload: response }) dispatch({ type: 'USER_LOGIN', payload: response })
return(response)
}; };

View file

@ -63,9 +63,16 @@ class AuthMenu extends Component {
handleLogin() { handleLogin() {
this.props.userLogin(this.state.username, this.state.password) this.props.userLogin(this.state.username, this.state.password)
.then(res => {
this.setState(state => ({ this.setState(state => ({
auth_menu_visible: false, auth_menu_visible: false
})); }))
console.log(res)
}
)
.catch(err => {
console.log(err);
})
} }
handleCreateAccount() { handleCreateAccount() {

View file

@ -7,7 +7,7 @@ const initialState = {
export default (state = initialState, action) => { export default (state = initialState, action) => {
switch (action.type) { switch (action.type) {
case 'USER_LOGIN': case 'USER_LOGIN':
return {jwt: action.payload} return {...state, ...{jwt: action.payload}}
default: default:
return state; return state;
} }