Open sahat opened 8 years ago
I was able to fix this issue with the following lines in server.js
(around line 102):
// React server rendering
app.use(function(req, res) {
var cookieToken = req.cookies.token;
var tokenUser = req.user;
if (cookieToken && (tokenUser === null)) { // Okay so we've got a token but no user
cookieToken = '';
res.cookie('token', '', {expires: new Date(0) }); // delete the cookie
}
var initialState = {
auth: { token: cookieToken, user: tokenUser }, // carry on as usual
messages: {}
};
var store = configureStore(initialState);
If a user has been manually deleted from the database or no longer exists for whatever reason, a cookie - that normally gets deleted during logout - should be automatically cleared from the Browser.