Skip to content

Instantly share code, notes, and snippets.

@bnhansn
Created October 21, 2016 15:57
Show Gist options
  • Save bnhansn/7a42e18efcb9767b9183429fed8c3c74 to your computer and use it in GitHub Desktop.
Save bnhansn/7a42e18efcb9767b9183429fed8c3c74 to your computer and use it in GitHub Desktop.
const initialState = {
isAuthenticated: false,
willAuthenticate: true,
currentUser: {},
};
export default function (state = initialState, action) {
switch (action.type) {
case 'AUTHENTICATION_REQUEST':
return {
...state,
willAuthenticate: true,
};
case 'AUTHENTICATION_SUCCESS':
return {
...state,
willAuthenticate: false,
isAuthenticated: true,
currentUser: action.response.data,
};
case 'AUTHENTICATION_FAILURE':
return {
...state,
willAuthenticate: false,
};
case 'LOGOUT':
return {
...state,
willAuthenticate: false,
isAuthenticated: false,
currentUser: {},
};
default:
return state;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment