From dcca50671c3d6094fca3fb5f7deb598cf78b49d2 Mon Sep 17 00:00:00 2001 From: Lucas BEE Date: Sun, 14 Oct 2018 13:53:05 +1000 Subject: [PATCH] Handle login error in the USER_LOGIN_ERROR event --- frontend/js/reducers/users.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/frontend/js/reducers/users.js b/frontend/js/reducers/users.js index 116f4d6..9195f13 100644 --- a/frontend/js/reducers/users.js +++ b/frontend/js/reducers/users.js @@ -16,10 +16,11 @@ const defaultState = Map({ const handlers = { "USER_LOGIN_PENDING": state => state.set("loading", true), + "USER_LOGIN_ERROR": state => { + state.set("loading", false) + return logoutUser() + }, "USER_LOGIN_FULFILLED": (state, action) => { - if (action.payload.response.status === "error") { - return logoutUser() - } return updateFromToken(state, action.payload.response.data.token) }, "USER_SET_TOKEN": (state, action) => updateFromToken(state, action.payload.token),