Skip to content

Instantly share code, notes, and snippets.

@s-petersson
Created August 16, 2015 20:32
Show Gist options
  • Save s-petersson/2a7243cc9d0e656f99d0 to your computer and use it in GitHub Desktop.
Save s-petersson/2a7243cc9d0e656f99d0 to your computer and use it in GitHub Desktop.
function loginSuccess (router) {
return (dispatch, getState) => {
const state = getState();
console.log('test');
let nextPath = state.router.query ? state.router.query.next : '/home';
// TODO: Swap these two, when React 0.14 is released.
// dispatch(transitionTo(state.router.query.next));
router.transitionTo(nextPath);
};
}
export function login (email, password, router) {
return {
types: [LOGIN, LOGIN_SUCCESS, LOGIN_ERROR],
payload: {
promise: authenticate(email, password),
onSuccessAction: loginSuccess(router)
}
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment