Merge pull request #521 from sharetribe/fix-auth-logout-error

Fix error when data was being loaded while logout was in progress
This commit is contained in:
Kimmo Puputti 2017-10-27 09:25:52 +03:00 committed by GitHub
commit 610ee43751
2 changed files with 6 additions and 5 deletions

View file

@ -151,15 +151,16 @@ export const logout = () => (dispatch, getState, sdk) => {
}
dispatch(logoutRequest());
// Not that the thunk does not reject when the logout fails, it
// Note that the thunk does not reject when the logout fails, it
// just dispatches the logout error action.
return sdk
.logout()
.then(() => dispatch(clearCurrentUser()))
.then(() => dispatch(logoutSuccess()))
.then(() => {
dispatch(userLogout());
// The order of the dispatched actions
dispatch(logoutSuccess());
dispatch(clearCurrentUser());
log.clearUserId();
dispatch(userLogout());
})
.catch(e => dispatch(logoutError(storableError(e))));
};

View file

@ -274,8 +274,8 @@ describe('Auth duck', () => {
expect(sdk.logout.mock.calls.length).toEqual(1);
expect(dispatch.mock.calls).toEqual([
[logoutRequest()],
[clearCurrentUser()],
[logoutSuccess()],
[clearCurrentUser()],
[userLogout()],
]);
});