Flesh out the state wiring for auth
This commit is contained in:
parent
251c3fc25d
commit
bbb64c4111
3 changed files with 12 additions and 4 deletions
|
@ -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)
|
||||||
};
|
};
|
||||||
|
|
|
@ -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() {
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue