erikras / erikras/react-redux-universal-hot-example

Logout when some errors are raised

Open
#1,194 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
12.1k
Forks
2.5k
PR merge metrics
No merged PRs in 30d

Description

Hello,

I have many reducers whose load ressources, users, groups, modules etc... When the client session expires I raise this error from one of my middlewares :

`res.status(500).send({ error: 'You are disconnected' })`;

Then it triggers the LOAD_FAILS of the current reducer. I would like to trigger a logout each time this error is raised whatever the reducer is.

I don't know where I can catch and analyse this error to do so, I just catch it in my reducer but maybe I should catch it higher.

To logout I do like this :

```
const appReducer = combineReducers({
routing: routeReducer,
reduxAsyncConnect,
auth,
form,
multireducer: multireducer({
counter1: counter,
counter2: counter,
counter3: counter
}),
info,
widgets,
clients,
fiches,
groups,
users,
modules,
supervision,
});

const rootReducer = (state, action) => {
if (action.type === 'server-sts/auth/LOGOUT_SUCCESS') {
console.log('state reseted')
state = undefined
}
return appReducer(state, action)
}

export default rootReducer;

```

Do you know how I can

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.