auth0-blog / redux-auth

MIT License
384 stars 69 forks source link

Logout reducers #9

Open sylvainlap opened 8 years ago

sylvainlap commented 8 years ago

There are some issues with your Logout reducers:

case LOGOUT_SUCCESS:
      return Object.assign({}, state, {
        isFetching: true,
        isAuthenticated: false
      })

In case of success, isFetching shall be set to false.

Moreover, LOGOUT_REQUEST is missing.

williamsb commented 6 years ago

@sylvainlap In the actions file there is this function logoutUser which first dispatches requestLogout ( where isFetching=true) and then afterwards receiveLogout ( where isFetching=false).

// Logs the user out
export function logoutUser() {
  return dispatch => {
    dispatch(requestLogout())
    localStorage.removeItem('id_token')
    dispatch(receiveLogout())
  }
}

However, LOGOUT_REQUEST is missing from the auth reducer. I just added it myself to my project, I'm rewriting this in typescript.

williamsb commented 6 years ago

also, just to add on to this, in LOGOUT_REQUEST user creds are added but never cleared.