Skip to content

Instantly share code, notes, and snippets.

@bnhansn
Created October 21, 2016 15:54
Show Gist options
  • Save bnhansn/174ec876c2278379e32f10752b61c203 to your computer and use it in GitHub Desktop.
Save bnhansn/174ec876c2278379e32f10752b61c203 to your computer and use it in GitHub Desktop.
export function authenticate() {
return (dispatch) => {
dispatch({ type: 'AUTHENTICATION_REQUEST' });
return api.post('/sessions/refresh')
.then((response) => {
setCurrentUser(dispatch, response);
})
.catch(() => {
localStorage.removeItem('token');
window.location = '/login';
});
};
}
export const unauthenticate = () => ({ type: 'AUTHENTICATION_FAILURE' });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment